2012-05-30 95 views
0

我下面.htaccess文件:阿帕奇,改寫和的.htaccess misterium

RewriteEngine On 
RewriteBase/
RewriteRule ^plugins/.* pluginLoader.php [L] 
RewriteRule ^settings\.php index.php [L] 
RewriteCond %{REQUEST_FILENAME} !-f [OR] 
RewriteCond %{REQUEST_FILENAME} \.art$ [OR] 
RewriteCond %{REQUEST_FILENAME} /system/ 
RewriteRule .* index.php [L] 

它的工作原理,如何預計,直到URL指向現有文件的名稱不帶擴展名位於plugins目錄。我不知道爲什麼。例如有一個/plugins/invoice/name.txt文件。

http://localhost/plugins/invoice/name.txt 
    uses pluginLoader.php as expected 
http://localhost/plugins/invoice/name. 
    uses pluginLoader.php as expected 
http://localhost/plugins/invoice/name 
    uses index.php! Why? 
http://localhost/plugins/invoice/nam 
    uses pluginLoader.php as expected 

這同樣適用於有.txt.php擴展名的文件。如果該文件有.sql擴展名,它既不使用pluginLoader.php也不使用index.php。它發送404 - 未找到

有沒有一些預處理器?

什麼也很有趣:

RewriteEngine On 
RewriteBase/
RewriteRule ^plugins/.* pluginLoader.php [L] 
RewriteRule ^settings\.php index.php [L] 

要刪除最後四行使得它的工作。但URL http://localhost/plugins/invoice/fill仍然收到404錯誤。當文件重命名後,該URL起作用。

神祕...

+0

最好的調試方法(因爲它可以只針對你的系統) - 在最高級別啓用重寫調試並分析日誌(我希望你在你的本地/ dev服務器上進行測試,該服務器很少或沒有流量,否則日誌文件會變得很大並且很難調試)。 http://httpd.apache.org/docs/current/mod/mod_rewrite.html#logging(對於2.4,如果你在2.2分支上,那麼http://httpd.apache.org/docs/2.2/mod/mod_rewrite .html#rewritelog) – LazyOne

+0

'選項-MultiViews'應該修復'name-clash'問題 – Gerben

回答

0

本替換你的.htaccess代碼,看看是否有幫助:

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

RewriteRule ^plugins/ pluginLoader.php [L,NC] 

RewriteRule ^settings\.php/?$ index.php [L,NC] 

RewriteCond %{REQUEST_FILENAME} !-f [OR] 
RewriteCond %{REQUEST_FILENAME} \.art$ [OR] 
RewriteCond %{REQUEST_FILENAME} /system/ 
RewriteRule^index.php [L] 

確保有在$DOCUMENT_ROOT/plugins目錄中沒有的.htaccess。