Thanks a lot for the responses, unfortunately I still couldnt get this working using and of the methods. Seems like it quite complicated to redirect a dynamic page.
Thanks a lot for the responses, unfortunately I still couldnt get this working using and of the methods. Seems like it quite complicated to redirect a dynamic page.
http://www.usconverters.com/ << this is not a URL to a page
http://www.usconverters.com/index.php << this is a URL to a page
Which is why I mentioned earlier about first creating the page to be redirected to. Otherwise, we know life will get in the way and it could weeks or months before that page is created. In the meantime, you will have a lot of confused people and possibly missed Sales.
And using any type of SEO module for "pretty URLs" could cause problems with the redirect.
Did anybody find out how to 301 redirect a single product page?
I tried all the suggestions in this thread but nothing works. I have no URL mods or anyhting like that installed.
Top of your .htaccess file should contain:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /store/
Note: Replace /store/ with the relative web path of your catalog. If store is in the root then just use: /
example: RewriteBase /
Then add:
#Old store URLs
RewriteRule ^OLD-PRODUCT\.html$ "http\:\/\/www\.YOURDOMAIN\.com\/NEW-PRODUCT\.html" [R=301,L]
RewriteRule ^OLD-PRODUCT2\.html$ "http\:\/\/www\.YOURDOMAIN\.com\/NEW-PRODUCT2\.html" [R=301,L]
So your .htaccess will contain:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /store/
#Old store URLs
RewriteRule ^OLD-PRODUCT\.html$ "http\:\/\/www\.YOURDOMAIN\.com\/NEW-PRODUCT\.html" [R=301,L]
RewriteRule ^OLD-PRODUCT2\.html$ "http\:\/\/www\.YOURDOMAIN\.com\/NEW-PRODUCT2\.html" [R=301,L]
Please disregard the post immediately above.
You'll need this in the root .htaccess file:This redirects product ID 221 for all categories, for both www and non-www requests, and whether or not "index.php" is within the request.Code:RewriteEngine On RewriteCond %{QUERY_STRING} ^main_page=product_info&cPath=([0-9]+)&products_id=221$ [NC] RewriteRule ^zencart/(index\.php)?$ http://www.example.com/? [R=301,L]
Change "zencart/" to your real folder name. Remove the "zencart/" part if the site is in the root folder. Note the trailing slash is also deleted.
Final point. Never mix RewriteRule directives with Redirect or RedirectMatch directives within the same site. If you do, you can never be quite sure of the processing order. By mixing them up, you're using directives from two different Apache modules. Stick to just using RewriteRule for all directives.
Last edited by Ajeh; 3 May 2010 at 04:17 PM. Reason: fix missing ?
Those two URLs are Duplicate Content for your site root. Only one of those should return 200 OK HTTP status.
The canonical URL is the one without the default index filename included.
The other should redirect to the canonical URL:If the store is located in a folder, add "/foldername" to both of the RewriteConds directly before the /index and before the /(index\.php) parts, and to the RewriteRule between the ^ and index\.php and between the ^ and (index\.php) parts, but add these in only the first two rulesets.Code:# Index Redirect for /index.php request with no parameters RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ RewriteRule ^index\.php$ http://www.example.com/? [R=301,L] # Index Redirect for /(index.php)?main_page=index(&cPath=<blank>) request RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(index\.php)?\?main_page=index(&cPath=)?\ HTTP/ RewriteRule ^(index\.php)?$ http://www.example.com/? [R=301,L] # Redirect non-www and/or trailing port number etc, to www RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ RewriteRule (.*) http://www.example.com/$1 [R=301,L] # ErrorDocument ErrorDocument 404 /index.php?main_page=page_not_found
There's several problems with your code.
Firstly, it takes no account of query strings so cannot be used to solve this ZenCart question; and secondly, the literal target URL should not have any escaping within. Escaping is needed on literal periods, etc, only within the RegEx pattern (the bit "on the left"). Your code is also redirecting from folder to root, as the target URL does not contain a folder.
Last edited by g1smd; 3 May 2010 at 07:15 AM.
For redirecting from /folder/ to root, you might find this code is a bit cleaner: http://www.zen-cart.com/forum/showth...=150620&page=2
Adjust the first chunk to suit your osCommerce URLs and place it in that folder. Ensure the second chunk, in the root, includes an exclusion for both the admin folder and for the folder where the osCommerce site used to reside (that's the !^/(admin|zencart) part of the code).
Bookmarks