我正在使用mod_rewrite將所有請求路由到index.php。。使用別名URI時忽略.htaccess
我的文件夾結構如下:
/Users/Peter/Projects/Framework
/.htaccess
/index.php
在我的.htaccess文件我有以下幾點:
RewriteEngine on
RewriteCond $1 !^index\.php/
RewriteRule ^(.*)$ index.php/$1 [L]
當我訪問projects.localhost/framework/example
這工作得很好。
我也有以下別名設置: 別名/〜別名/用戶/彼得/項目
當我瀏覽到http://projects.localhost/~alias/framework/example
我得到一個404錯誤,在我的錯誤日誌中的:File does not exist: /Users/Peter/Projects/framework/example
當我使用別名URL時,似乎沒有調用.htaccess文件(在使用別名URL時,輸入giberish到.htaccess文件不會觸發任何類型的錯誤似乎證實了這一點)。
AllowOveride設置爲All。
如何在使用別名URL時使.htaccess工作,並且無論URL如何(別名或不別名)都重寫規則一致地應用?
編輯:導航到projects.localhost/~alias/framework/index.php/example
也工作正常,確認別名工作正常(除了沒有應用.htaccess規則)。
別名似乎繞過正常的根,因此.htaccess文件放在那裏。你可以在'/ Users/Peter/Projects'文件夾中加入另一個.htaccess文件 – Gerben
我已經嘗試在項目文件夾中放置一個.htaccess文件,但這對別名URL也沒有影響。 (它確實會影響不帶別名的url。) –