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?
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]
Related
i need to do some simple 301 redirects as i am creating a site fresh and using the current domain.
How ever the website URl's all start with '?'.
For example:
Redirect 301 /?q=news http://websitedomain/news/
This results in the home page being loaded with the url still the same.
Is there any way to get around this?
You need to use mod_rewrite to match against the query string :
RewriteEngine on
RewriteCond %{QUERY_STRING} ^q=([^&]+) [NC]
RewriteRule ^ http://example.com/%1? [NC,L,R]
I need to redirect URL, for example:
www.mydomain.com/category/sub-category/product?page=shop.ask&flypage=flypage.tpl&product_id=181&category_id=34
To:
www.mydomain.com/category/sub-category/good-product.html
I have a multiple URLs with parameters that need to be redirected to only one or couple of URLs, can you help me, I used Google for hours.
I was try this code at .htaccess:
redirect 301 /category/sub-category/product?page=shop.ask&flypage=flypage.tpl&product_id=181&category_id=34 www.mydomain.com/category/sub-category/good-product.html
But it doesn't work.
You can't match against the query string in a Redirect directive. You'll need to use mod_rewrite:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^page=shop.ask&flypage=flypage.tpl&product_id=181&category_id=34$
RewriteRule ^category/sub-category/product$ /category/sub-category/good-product.html? [L,R=301]
I need to redirect my website to a new domain name but I want it to also redirect all of the pages. I want www.myoldsite.com/ to redirect to www.mynewsite.com/ but I also want all of the pages to redirect.
For example: www.myoldsite.com/faq to redirect to www.mynewsite.com/faq and so forth and so on. I know how to do it by doing each individual page but I have a lot of pages. How do I rewrite the 301 for it to basically change the root domain name but keep the directories and pages the same? Thanks a million!
You just need this in the htaccess file in your old domain's document root:
Redirect 301 / http://www.mynewsite.com/
If both your old site and new site share the same document root, then you need mod_rewrite instead:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?myoldsite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mynewsite.com/$1 [L,R=301]
I have pages indexed by Google such as sample.com/product-detail.cfm?id=532323. There are a lot of these pages. These pages no longer exist and I would like to redirect all of them to the home page of our new site. Can anyone suggest how to redirect all of the pages without having to do each one individually?
All of them should go to the home page
Then you can just check for /product-detail.cfm and ignore the id= param in the query string. You can do this with either mod_alias or mod_rewrite by adding these directives in the htaccess file in your document root:
Using mod_alias:
Redirect 301 /product-detail.cfm /
Using mod_rewrite:
RewriteEngine On
RewriteRule ^product-detail.cfm$ / [L,R=301]
I've looked all over for the htaccess code to redirect a single page and haven't had any luck with many solutions.
Basically I need to redirect this:
/example/my-stuff/
to:
/example/home/
but I don't want any other pages except for /my-stuff/ to be redirected. Eg. these pages should not be redirected and kept the same.
/example/my-stuff/a-page
/example/my-stuff/anything
In the htaccess file in your document root, you can add either this:
RedirectMatch 301 ^/example/my-stuff/$ /example/home/
Or you can use mod_rewrite instead:
RewriteEngine On
RewriteRule ^example/my-stuff/$ /example/home/ [L,R=301]