Search code examples
.htaccesshttp-redirecthttp-status-code-301

htaccess 301 Redirect with querystring


In my htaccess I want to do 301 redirects from all of the products that use the standarddetail page

https://www.domain.com/standarddetail.asp​?cid=4135

To the following page: https://www.domain.com/index.php?route=product/product&product_id=4135

I want to do this for all (cid) query strings

I have a couple of thousand products that appear on this standarddetail.asp page using the querystring (cid) and I want them to go to the new page using the product_id= querystring.

I want them to be 301 redirects.

How is this done?


Solution

  • In the htaccess file in your document root, add this:

    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^cid=([0-9]+)
    RewriteRule ^standarddetail\.asp$ index.php?route=product/product&product_id=%1 [L,R=301]