Synyster Synyster - 8 months ago 27
PHP Question

Htaccess rewriterule doesn't seem to work

I'm trying to rewrite the file


I have made a rewrite row in my .htaccess file and it's the following:

RewriteRule ^forums/(.*)/(.*) view-forums.php?page=$1&section=$2
The url should then be http://localhost/forums/community-forums/2846 but it doesn't work when I visit it. It sends me to an error page instead, any ideas?

My full 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


You should make the regex lazy, otherwise the first capture group "eats" the second one. Try also escaping /.

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