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 vc6.0中想运行代码的时候总是提示无法打开文件是怎么回事
  • ¥25 关于##爬虫##的问题,如何解决?:
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题