Htaccess rewriterule似乎不起作用

时间:2016-08-06 13:55:26

标签: php .htaccess

我试图重写文件

view-forums.php?page=community-forums&section=2846

我在.htaccess文件中创建了一个重写行,它包含以下内容:

RewriteRule ^forums/(.*)/(.*) view-forums.php?page=$1&section=$2网址应该是http://localhost/forums/community-forums/2846,但是当我访问它时它不起作用。它发送给我一个错误页面,任何想法?

我的完整htaccess:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)/(.*) index.php?page=$1&id=$2

RewriteRule ^forums/(.*)/(.*) view-forums.php?page=$1&section=$2

RewriteRule ^media$ media.php

RewriteRule ^about-us$ about.php

RewriteRule ^forums$ main-forums.php

1 个答案:

答案 0 :(得分:0)

你应该使正则表达式懒惰,否则第一个捕获组“吃掉”第二个。尝试转义/

RewriteRule ^forums\/(.*?)\/(.*) view-forums.php?page=$1&section=$2