2012-05-30 94 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。