.htaccess - url redirect exact match including params -


i make 301 redirect , old website using exact exact url no parameters.

example:

/en-direct.php?page=7 

to go to:

http://www.example.org/news/ 

and page:

/en-direct.php?page=8 

to go to:

http://www.example.org/awesome-but-totally-different-page/ 

i used:

redirectmatch 301 ^/en-direct.php$ http://www.example.org/different-page/ redirectmatch 301 ^/en-direct.php?page=7$ http://www.example.org/news/ redirectmatch 301 ^/en-direct.php?page=8$ http://www.example.org/awesome-but-totally-different-page/ 

however: http://www.example.org/different-page/ every time parameters redirect page (example - http://www.example.org/different-page?page=7 )

any appreciated.

in order match against query string, need use mod_rewrite:

rewriteengine on  rewritecond %{query_string} ^page=7($|&) rewriterule ^en-direct\.php$ http://www.example.org/news/ [l,r=301]  rewritecond %{query_string} ^page=8($|&) rewriterule ^en-direct\.php$ http://www.example.org/awesome-but-totally-different-page/ [l,r=301]  rewritecond %{query_string} ^$ rewriterule ^en-direct\.php$ http://www.example.org/different-page/ [l,r=301] 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -