Apache mod rewrite question:/test/method被重写为test.svg/method
我注意到(对我来说)发生了一件奇怪的事。修复它对我来说并不重要,重要的是弄清楚到底发生了什么。基本上,我的文档根目录中有一个名为Apache mod rewrite question:/test/method被重写为test.svg/method,apache,mod-rewrite,Apache,Mod Rewrite,我注意到(对我来说)发生了一件奇怪的事。修复它对我来说并不重要,重要的是弄清楚到底发生了什么。基本上,我的文档根目录中有一个名为test.svg的svg文件,还有一个index.php。根据我的.htaccess文件,我的期望是访问http://localhost/test.svg会在访问http://localhost/test/action将被重写为index.php/test/action。相反,当我收到消息时,后者显然被重写为test.svg/action 在此服务器上找不到请求的URL
test.svg
的svg文件,还有一个index.php
。根据我的.htaccess
文件,我的期望是访问http://localhost/test.svg
会在访问http://localhost/test/action
将被重写为index.php/test/action
。相反,当我收到消息时,后者显然被重写为test.svg/action
在此服务器上找不到请求的URL/test.svg/action
这是我的.htaccess
文件:
# Turn on URL rewriting
RewriteEngine On
# Protect application and system files from being viewed
# RewriteRule ^(application|modules|system) - [F,L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]
我在Ubuntu上使用Apache2.2.12(通过apt get
安装)。我认为我的设置相当标准,但我不确定哪些指令或配置文件是相关的。我绝不是任何类型的系统管理员,我只是使用这个服务器在本地测试和开发东西
正如我所说的,解决这个问题是微不足道的,我只是经常被
mod_rewrite
弄糊涂,并想了解这里发生了什么。Apache的HTTP内容协商功能正在自动从“/test”转换为“/test.svg”。看
您可以使用以下指令禁用.htaccess中的内容协商:
Options -MultiViews
通过将这些指令添加到Apache配置中,您可以获得有关mod_rewrite正在做什么的更多信息(它们在.htaccess中不起作用):
RewriteLogLevel可以是0(已禁用)到9(非常详细)之间的任意数字。3应该给您足够的时间来查看发生了什么,但不要在生产服务器上使用它
RewriteLog /path/to/rewrite.log
RewriteLogLevel 3