我真的很困惑,我想使用htaccess Rewrite将一个有参数的url重写为一个没有参数的url。这是我的.htaccess文件:
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^sitemap.xml$ sitemap.php [NC] # Handle requests for "sitemap"
RewriteRule ^category/([A-Za-z0-9-]+)/$ displaycategory.php?category_name=$1 [NC] # Handle requests for "categories"
RewriteRule ^items/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)$ item.php?category_name=$1&id=$2 [NC] # Handle requests for "single item"
规则1和规则3运行良好,但第二个url重定向到index.php
如果我调用这个网址:
http://example.de/category/test/
它重定向到
http://example.de/category/test/index.php
.htaccess重写规则是正确的,我认为不是这导致了问题。如果您有一个名为test的目录或另一个非常接近测试的文件,那么Apache多视图可能会出现问题。您是否可以访问服务器日志?我敢打赌,服务器配置中有一些东西阻止了规则的正常工作。