给定一个URL:
http://example.com/some-file.zip
example.com的文档根目录是/var/www/example.com/
我想要apache:
1) If /var/www/example.com/some-file.zip exists, serve it. 2) If /var/www/example.com/some-file.zip doesn't exist, check /var/www/shared/some-file.zip 3) If /var/www/shared/some-file.zip doesn't exist, send a 404
这可能吗?
我查看了Alias指令,但是我认为这将需要我在URI中指定资源的位置。
对于DocumentRoot之外的DocumentRoot ,请查看“ DocumentRoot之外的文件 ”上恰当命名的文档部分 – 您正在创build一个Alias ,而且您可能无需redirect即可完成此操作。
RewriteCond %{DOCUMENT_ROOT}$1 !-f RewriteRule (.*) /var/www/shared$1 [last]