douliu8327 2014-10-25 08:13
浏览 185
已采纳

htaccess RewriteRule重定向到index.php

I am really puzzeld, I want to use htaccess Rewrite to rewrite an url with parameter to one without. This is my .htaccess file:

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"

Rule 1 and rule 3 are working fine, but the second url redirects to index.php

If I call this url:

http://example.de/category/test/

it redirects to

http://example.de/category/test/index.php

  • 写回答

1条回答 默认 最新

  • doujia1679 2014-10-25 09:48
    关注

    Your .htaccess rewrite rule is correct, and I assume its not this causing the problem. If you have a directory called test or another file very close to test Apache Multiviews could be the problem. Have you access to server logs? I bet there is something in the server config preventing the rule from working correctly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么