我有一個應用程序在幾個不同的環境中運行,有時它在一個站點的頂層或有時在一個別名內運行。在Apache別名內匹配的RewriteRules
當它是一個直接結算到正常的文檔根我的.htaccess是這樣的:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
我在那有一個像下面的別名的環境中部署的網站:
Alias /foo /path/to/my/application/
我發現我不得不修改.htaccess以下內容:
RewriteEngine On
RewriteBase /foo
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /foo/index.php [NC,L]
我的問題是,如何我是否可以重寫我的.htaccess,以便重寫的工作方式與別名相同?有什麼方法可以檢測到是否設置了別名,或者其他方式來表示RewriteRules?
你有沒有想出解決辦法? – Andre 2013-06-18 23:44:29