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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -