0
votes

I have a webshop in asp language that will be renewed to a php webshop. There are still many url's and links from the old webshop stored on different websites that I want to revert to the homepage of the new webshop.I'm looking for example for the correct rule to redirect the following url in my .htaccess file:

http://www.example.com/shopdisplayproducts.asp?id=15&cat=football to http://www.example.com

Could you show me this example, so I might be able to make the other redirects myself. I have tried for example this, but without success:

RewriteRule ^shopdisplayproducts* index.php [R=301,L]

Thanks for your input Regards, Vicef

1

1 Answers

1
votes

If you want a catch-all URL that will match regardless of the query string you could use

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule ^shopdisplayproducts\.asp / [L,R=301]

If you want to match the query string as well you need to add two lines

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{QUERY_STRING} id=15
RewriteCond %{QUERY_STRING} cat=football
RewriteRule ^shopdisplayproducts\.asp / [L,R=301]

While testing it's better to use R=302 instead of R=301 because browsers cache 301 responses, so if you change the rule you won't see the effect because the browser is still executing the cached result. When you use 302 you don't have this problem. So start with 302 and once it works replace that with 301.

Also, please be aware that redirecting everything to the homepage of a new site is almost never a good idea in terms of SERP ranking. If there is a new URL for a certain page it's better to rewrite to that URL. If there isn't, you might want to consider just letting it 404 so search engines will just remove them from their results.