php - htaccess: different url for same page doesn't work -
i've got these lines in htaccess file:
rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php?page=$1 [nc] rewriterule ^(.*)/(.*)$ index.php?page=$1&article=$2 [nc] when comes address /news/test, page variable index.php. idea how fix that?
you have (.*) matching in first row match both scenarios.
try out worked me in following scenarios:
rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)/(.*)$ /index.php?page=$1&article=$2 [l] rewriterule ^(.*)$ /index.php?page=$1 [l] it worked for:
http://www.example.com/news/test -> http://www.example.com/index.php?page=news&article=test http://www.example.com/news/ -> http://www.example.com/index.php?page=news&article= http://www.example.com/news -> http://www.example.com/index.php?page=news let me know, if need else. test have added [l,r=302] instead of [l] see if url forming correct or not.
Comments
Post a Comment