simon
simon

Reputation: 2377

Seo 301 absolute url redirects, Prestashop

I am cleaning up some old stuff and I need to do some 301 redirects.

For example:

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

Upvotes: 0

Views: 476

Answers (2)

Serge P
Serge P

Reputation: 1863

mod_alias is designed to handle simple URL manipulation tasks. For more complicated tasks such as manipulating the query string, use the tools provided by mod_rewrite.

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.

Upvotes: 1

anubhava
anubhava

Reputation: 785128

You cannot match query string using RedirectMatch directive. Use mod_rewrite rule instead:

RewriteEngine On

RewriteCond %{QUERY_STRING} product=371&sub=0&page=1
RewriteRule ^product\.asp$ /category/test/? [L,NC,R=301]

? in the target is to strip off existing query string.

Upvotes: 1

Related Questions