I am cleaning up some old stuff and I need to do some 301 redirects.
For example:
-
I have following absolute url: http://mysite.dk/product.asp?product=371&sub=0&page=1
-
That i need to redirect to:
http://mysite.dk/category/test
I have tried with htaccess:
RedirectMatch 301 /product.asp?product=371&sub=0&page=1 /category/test
But above code will not work, It is showing the 404 page and ignoring the redirect I just made. Note please that product.asp does not exists as a file!
However if I use:
RedirectMatch 301 /product.asp /category/test/
It works sort off, but now I can’t do redirects, based on the query string for that specific file.
Any suggestions? Btw I am using Prestashop=)
Best, Simon
2
Answers
You cannot match query string using
RedirectMatch
directive. Usemod_rewrite
rule instead:?
in the target is to strip off existing query string.from here
Just add the rules from @anubhava answer into Prestashop .htaccess and it will works. Better to do it before
# ~~start~~
line, you will see notice in the file.