我應該設置什麼規則,使mod_rewrite的忽略目錄「公衆」徹底?因此,我的意思是,文件應該可以在其中訪問,但如果文件不存在,服務器錯誤頁面應該會出現類似於FORBIDDEN或FILE NOT FOUND之類的東西。我不需要自定義錯誤頁面或類似的東西。我只是希望「公共」的行爲就像沒有mod_rewrite一樣。PHP國防部重寫的.htaccess忽略目錄
這裏是我的.htaccess文件:
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
我的文件結構
/system/
/application/
/public/
我想要的文件夾公衆的行爲,像有設置完全沒有重寫規則,完全無視它。
編輯
這是我的.htaccess文件:
RewriteEngine on
RewriteRule ^(public)($|/) - [L,NC]
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
我已經在/公/文件夾中有這樣的.htaccess:
RewriteEngine off
我已經嘗試了所有的上面的不同答案(和谷歌一噸)。我試圖把他們混合在一起。
我的文件夾:
/system/
/application/
/public/
/public/.htaccess #RewriteEngine off
/public/favicon.ico
/index.php
下面是與結果我得到的網址:
/public/favicon.ico -> I get the favicon
/public/faviDon.ico -> I get the index.php (without mod rewrite you would get "not found")
/public/ -> I get the index.php (without mod rewrite "forbidden")
所以它仍然重寫URL,如果沒有找到該文件,或者在訪問文件夾直接。
你能瑟呢?
非常感謝你的努力的傢伙!對此,我真的非常感激!
更適合serverfault.com – ethrbunny
如果'public'是web根目錄,那麼''忽略'就你網站的網址而言。 – 2013-01-23 19:57:54
檢查我的編輯請 –