Search code examples
apache.htaccessmod-rewriteurl-rewritingfriendly-url

htaccess doesn't work with included ampersand


I need to pass additional get variable, but it doesnt work with the ampersand. Any ideas what im doing wrong? (last line)

First 3 lines work just fine.

RewriteRule ^forums forum.php [NC,L]
RewriteRule ^fc/([0-9]+) forum.php?fc=$1 [NC,L]
RewriteRule ^ft/([0-9]+) forum.php?ft=$1 [NC,L]
RewriteRule ^ft/([0-9]+)/(0-9]+) forum.php?ft=$1&e=$2 [NC,L]

Solution

  • Have your htaccess in following manner. You could reduce from 4 rules to 3 rules. You need to place anchors in regex to avoid false positive matches while uri matches in Rules.

    Please make sure you are clearing your browser cache before testing your URLs.

    RewriteEngine ON
    RewriteRule ^ft/([0-9]+)/([0-9]+)/?$ forum.php?ft=$1&e=$2 [NC,QSA,L]
    RewriteRule ^(fc|ft)/([0-9]+)/?$ forum.php?$1=$2 [NC,QSA,L]
    RewriteRule ^forums/?$ forum.php [NC,L]