Post by websteer » Wed Oct 27, 2010 10:05 pm

Hello all

I am trying to configure 301 redirects using the following in .htaccess

Code: Select all

redirect 301 "/old.htm" http://www.mydomain.co.uk/taps
It does not redirect, instead I get the following url in the address bar:

http://www.mydomain.co.uk/taps?_route_=old.htm

What am I doing wrong?

I am using ver: Version 1.4.9.2 with seo url's enabled. My store is in a development directory and the baseurl reflects this.

Any ideas please?

Thank you

DK

Newbie

Posts

Joined
Thu Mar 26, 2009 9:45 pm

Post by websteer » Wed Oct 27, 2010 11:48 pm

I have sorted it.

I was working against the RewriteEngine. So I have had to work with it. By redirecting to the original non seo friendly url. Then rewriting this to the new resource. So what normally be one line of code in the .htaccess file is now two:

Code: Select all

redirect 301 /Old_Resource http://www.mydomain.co.uk/index.php?route=product/category&path=37
RewriteCond %{QUERY_STRING} ^route=product/category&path=37$
RewriteRule ^index\.php$ http://www.mydomain.co.uk/new-resource? [R=301,L]
I hope this helps others?

So old indexed urls will still land in the right places from the search engines. And because Opencart is about 1000 times better than the old shopping cart, the world will be a better place. Thanks to Daniel and all.

Newbie

Posts

Joined
Thu Mar 26, 2009 9:45 pm

Post by elianderson » Wed Nov 10, 2010 11:15 pm

Thank you for your post, it helped me a ton!

Newbie

Posts

Joined
Wed Nov 10, 2010 11:14 pm

Post by puregeod » Fri Jul 15, 2011 9:10 pm

This post helped me a ton as well, many thanks websteer!

Newbie

Posts

Joined
Tue Jul 05, 2011 11:58 pm

Post by tabswear » Wed Dec 14, 2011 11:58 am

Many thanks for posting this. I've moved over from using OsCommerce and had just found a site linking to an out of date catagory url. This has saved me loosing the link. Thanks a lot for sharing the solution.

Embroidered promotional clothing supplier in the UK
Our webhost since Feb 2010 - http://bit.ly/soc5hK


User avatar
Newbie

Posts

Joined
Wed Dec 14, 2011 11:53 am
Location - UK

Post by peeveezee » Mon Jan 09, 2012 5:34 am

Hello

Do you need to do this for every url that you are redirecting?

Best regards,

Peter

Newbie

Posts

Joined
Wed Nov 23, 2011 5:41 pm

Post by albsim81 » Sun Jan 22, 2012 12:18 am

It doesn't work for me.
This is what does'nt work:

RewriteCond %{QUERY_STRING} ^/route=product/category&path=75$
RewriteRule ^index\.php$ http://spazio-natura.it/articoli-per-la-casa? [R=301,L]

Writing
http://spazio-natura.it/index.php?route ... ry&path=75
i should get http://spazio-natura.it/articoli-per-la-casa
but the url remains the first one.

This is all the .htacces:

Options +FollowSymlinks
Options -Indexes
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
RewriteEngine On

RewriteBase /
RewriteRule sitemap.xml /index.php?route=feed/google_sitemap
RewriteCond %{HTTP_HOST} ^www.spazio-natura.it$ [NC]
RewriteRule ^(.*)$ http://spazio-natura.it/$1 [R=301,L]
RewriteCond %{QUERY_STRING} ^/route=product/category&path=75$
RewriteRule ^index\.php$ http://spazio-natura.it/articoli-per-la-casa? [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

Sigaretta elettronica Opencart 1.5.4.1 italian translation


New member

Posts

Joined
Wed Jan 26, 2011 5:14 am
Location - Italy

Post by StaNislavB » Wed Feb 08, 2012 9:33 pm

thanx a lot!
works

Newbie

Posts

Joined
Wed Feb 08, 2012 9:32 pm

Post by hakedq » Tue Mar 13, 2012 3:57 am

I have the same problem as albsim81, the old url points to the correct page (index.php?route=product/category&path=xx) but there is no rewrite and change to the "correct" seo friendly url after that, anyone knows how to solve this?

Sajter: Provsmakning.se, RoligaJulklappar.se, Upplev.nu


New member

Posts

Joined
Tue Mar 13, 2012 1:04 am

Post by albsim81 » Wed Mar 14, 2012 3:45 am

I need to make a redirect
from
http://http://spazio-natura.it/kalumax-125-ml
to
http://http://spazio-natura.it/kalumax

I tried but I couldn't do it. Can you help me?

This is my .htaccess

Code: Select all

# 1.To use URL Alias you need to be running apache with mod_rewrite enabled. 

# 2. In your opencart directory rename htaccess.txt to .htaccess.

# For any support issues please visit: http://www.opencart.com

Options +FollowSymlinks

# Prevent Directoy listing 
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
 Order deny,allow
 Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/ 



RewriteBase /
RewriteRule sitemap.xml /index.php?route=feed/google_sitemap
RewriteCond %{HTTP_HOST} ^www.spazio-natura.it$ [NC]
RewriteRule ^(.*)$ http://spazio-natura.it/$1 [R=301,L] 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]






### Additional Settings that may need to be enabled for some servers 
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200


Sigaretta elettronica Opencart 1.5.4.1 italian translation


New member

Posts

Joined
Wed Jan 26, 2011 5:14 am
Location - Italy

Post by yu130960 » Mon Mar 26, 2012 12:22 pm

+1 I have the same question. Tried everything manually and in cpanel and I can not get opencart seo urls to do 301 redirects. Much appreciated.

Newbie

Posts

Joined
Fri Mar 09, 2012 11:04 pm

Post by hakedq » Mon Mar 26, 2012 5:50 pm

yu130960: adding a question mark to the redirects works for me, i.e:

redirect 301 /old-url http://www.example.com/new-url?

The only problem with this redirect is that you get a question mark in the url, but I don't think it's a major seo issue, specially not if you are using link rel="canonical" so Google knows which url is the correct one to index.

Sajter: Provsmakning.se, RoligaJulklappar.se, Upplev.nu


New member

Posts

Joined
Tue Mar 13, 2012 1:04 am

Post by shukshyna » Fri Jan 11, 2013 12:47 am

Thank you friend! The solution with redirecting to a non-friendly URL and rewriting after to SEO url worked for me (1.4.9.3)

The solution with /oldpage http://..../nepage? also works but I prefer not to add a question mark as I do not have rel canonical added for a reason.

Newbie

Posts

Joined
Wed Jan 02, 2013 9:53 pm

Post by MikeSCC » Mon Feb 04, 2013 8:28 pm

Very helpful, thank you.

Active Member

Posts

Joined
Tue Nov 20, 2012 5:55 pm

Post by helenkanta » Sat Aug 10, 2013 9:16 am

Hi Guys,

So you all look like you know what you're talking about here, and was hoping I can get some help. I'm know how to do some basic coding, but not exceptional by any means.

Basically, we have restructured our website and need to redirect a large number of pages. My .htaccess file looks like this (v 1.5.5.1):

Code: Select all

# 1.To use URL Alias you need to be running apache with mod_rewrite enabled. 

# 2. In your opencart directory rename htaccess.txt to .htaccess.

# For any support issues please visit: http://www.opencart.com

Options +FollowSymlinks

# Prevent Directoy listing 
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
 Order deny,allow
 Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/ 

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

### Additional Settings that may need to be enabled for some servers 
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200

# 7. disable open_basedir limitations
# php_admin_value open_basedir none


#301 redirect
Redirect 301 /onlinestore http://mywebsite.com.au
Redirect 301 /gallery.html http://mywebsite.com.au
Redirect 301 /Images/getaflatstomachoct2012.pdf http://mywebsite.com.au
Redirect 301 /onlinestore/all-products/allvia-melatonin-3-cream-57g http://mywebsite.com.au
Redirect 301 /aboutus.html http://mywebsite.com.au/about_us
Redirect 301 /meetus.html http://mywebsite.com.au/about_us
So the redirections continue for a large number of links. Can someone please help me with this? I tried adding question marks to the landing url, but only a few redirects works, not all of them.

Appreciate any direction. Thanks everyone.
Last edited by helenkanta on Wed Aug 14, 2013 9:41 am, edited 1 time in total.

New member

Posts

Joined
Thu Apr 28, 2011 4:06 pm

Post by helenkanta » Mon Aug 12, 2013 11:44 am

Hi guys,

sorry to sound impatient, if anyone can help asap that would be great. Even happy to pay for support if need be.

Regards,
Helen

New member

Posts

Joined
Thu Apr 28, 2011 4:06 pm

Post by stringsetc » Sun Aug 18, 2013 11:01 pm

hi helen,

did you ever get this sorted? I've got the same problem

Active Member

Posts

Joined
Thu Feb 16, 2012 11:59 pm

Post by helenkanta » Mon Aug 19, 2013 6:27 am

Not yet :( please someone... Anyone? I'm happy to pay for support! Please

New member

Posts

Joined
Thu Apr 28, 2011 4:06 pm

Post by webcookie » Tue Aug 20, 2013 9:36 pm

Hi Guys,

Thought I would post an update to help as I came across this problem also.

To 301 redirect old SEO keyword URLs (found on product & categories 'data' tab) to a new URL use the following format:

Code: Select all

RewriteRule ^seo-keyword$ http://www.example.co.uk/updated-seo-keyword/ [R=301,L]
That's not all though. That line above needs to be added to the .htaccess file directly after turning on the rewrite engine. See below for how it should look:

Code: Select all

# SEO URL Settings
RewriteEngine On

RewriteRule ^seo-keyword$ http://www.example.co.uk/updated-seo-keyword/ [R=301,L]

# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/ 

RewriteBase /
Obviously there is more code than this within the .htaccess, this is just the section in question.

Hope this helps someone floating around looking for a solution ;D

If anyone needs some support, contact me here: support--at--webcookie.co.uk
Simon, Web Cookie

Newbie

Posts

Joined
Sun Jan 13, 2013 10:58 pm


Post by diwakar007 » Wed Oct 15, 2014 3:30 pm

It doesn't work...
I want to change http://www.example.com/index.php?route= ... on/sitemap into http://www.example.com/sitemap

for this I write the following code....

Code: Select all

RewriteEngine on
RewriteRule ^sitemap$ index.php?route=information/sitemap [NC,L]
Is there any wrong in my code then please suggest me the correct one.

Thanks & Regards
Diwakar
SEO Freelancer Delhi - India


Newbie

Posts

Joined
Tue Oct 14, 2014 8:10 pm
Location - New Delhi, India
Who is online

Users browsing this forum: No registered users and 58 guests