Redirect old .asp links to new url

The site was initially hosted on a Windows Server and it was created using .asp programming language. Now it has been moved to a linux server running cPanel/WHM and the new site is built using WordPress and WooCoomerce (the site is an online shop).

I need to do some .htacess redirects from old .asp urls to the new links

Read More

Example:

old URL: http://website.com.au/products.asp?cat=110
new URL: http://www.website.com.au/product-category/pearls/

What I did try is:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

Redirect 301 /products.asp?cat=110 http://www.website.com.au/product-category/pearls/

For some reason the redirect is not working and I get a 404 page not found error.

Any help would be appreciated!

Related posts

1 comment

  1. You can not match against query strings in a Redirect Directive, you need to match against query strings using a rewriteCond, try:

    Options +FollowSymLinks -MultiViews
    # Turn mod_rewrite on
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{QUERY_STRING} ^cat=110$
    RewriteRule ^products.asp$ http://website.com.au/product-category/pearls/? [L,NC,R]
    

    An empty question mark at the end of the target url is important if you don’t want the old query strings to be appended to the target url.

Comments are closed.