I have a website using PHP-based CMS system.
So each page is generated dynamically, like this :
http://www.shuling.net.cn/index.php?_m=mod_product&_a=view&p_id=87
Now I want to redirect this specific page to another page, i.e.:
So I write .htaccess file as follows :
redirect 301 /index.php?_m=mod_product&_a=view&p_id=87 https://www.datanumen.com/sql-recovery/
But after I upload the .htaccess to the root directory of the website, this does not work at all.
I retest by writing another rule, like this:
redirect 301 /sql/ https://www.datanumen.com/sql-recovery/
Then this rule will work perfectly.
Why?
Thank you
Querystring is not part of match in Redirect directive, to redirect query strings, you need to use mod-rewrite as follows :
option 1
option 2
We use an empty question mark ? at the end of the target url to discard the old query strings, otherwise these query strings get appened to the target url by default.
Change the R to R=301 if you want to make the redirection permanent.
[Tested on apache2 and 2.4]