[英]Multiple DocumentRoot directives in Apache
我的問題與此類似,但有一個重要區別。 我希望能夠在主DocumentRoot中查找失敗的情況下提供文件,而不取決於文件的路徑。
在我的Apache服務器上,我希望能夠為我的網站設置多個DocumentRoot指令。 這樣,如果無法在主DocumentRoot文件夾中找到文件,則可以在另一個(公用)文件夾中查找。 這就是我的意思:
<VirtualHost *:80>
DocumentRoot /var/www/example/html
# insert additional document root here
# DocumentRootAlias /var/www/common/html
ServerName www.example.com
ServerAlias example.co
</VirtualHost>
我已經將全局DocumentRoot設置為/ var / www / common / html,但是如果當前的DocumentRoot失敗,我不知道如何在這里查看VirtualHost。
再次,如果服務器無法在.../example/html folder.
找到某些內容,我希望服務器在common文件夾中查找.../example/html folder.
Apache支持嗎?
將評論轉換為答案:
在所有重寫規則的末尾,輸入以下內容:
RewriteCond %{REQUEST_FLENAME} !-f
RewriteRule ^ /var/www/common/html%{REQUEST_URI} [L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.