跟踪一个奇怪的Apache重写

tl:dr; 你将如何去跟踪一个URL不应该发生重写


细节:我有一个.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] 

重写已启用。 当我访问如下的url:

foo.com/index.php我得到了我所期望的。 但是foo.com/index/会redirect到foo.com/index.htm

所以在我的应用程序路线,如foo.com/index/books/fiction将成为foo.com/index.htm/books/fiction

哪里可以设置? 我以为它可能在我的虚拟主机文件,但看起来像:

 <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> etc... 

这看起来很香草给我。 然后我可能是我的DirectoryIndex(位于apache2的启用mods的目录)需要指定,所以我改变了:

 <IfModule mod_dir.c> DirectoryIndex index.php index.phtml index.html </IfModule> 

但没有运气。 我不确定在哪里可以看。 有什么build议么?

在日志环境中激活debugging日志logging并调用该URL。 Apache应该创build一个详细的日志。 至less这是nginx在debugging模式下所做的。

我不知道为什么会发生这种情况,但你可以尝试:

 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^ index.php [L] 

而不是你的重写检查其他方式。 MultiViews也可能是一个问题。