Page 1 of 2
Help on 301 Redirect to Avoid Google Problems
Posted: Tue Oct 25, 2011 9:37 pm
by JoaniesGifts
Hi Guys,
I have a static html page (
http://www.joaniesgifts.co.uk) that links to my opencart store (
http://www.joaniesgifts.co.uk/store/).
I want to scrap the homepage, move all pages back a directory (so the store homepage is the homepage) and re-theme.
I've been told that if i do this Google will probably drop my rankings which i want to avoid at all costs.
I've also been advised to implement a 301 redirect.
Question is.....How?
I know i need to put something in the htaccess file but i've no idea what...
I need a 301 rule that works like this..
If a user visits a page with /store in the URL then remove the /store/ and take that as the new URL.
I'm not at al technical (especially with this sort of thing) but can follow instructions if they're clear.
Can someone help me?
Kind Regards,
Joan
p.s. I did google the problem but the solutions confused me i'm afraid

Re: Help on 301 Redirect to Avoid Google Problems
Posted: Wed Oct 26, 2011 6:25 am
by Avvici
Here is an example of a 301 redirect that basically redirects the person if they visit a sub folder. It can be customized to do what you need:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain.com
RewriteRule ^(.*)$
http://www.yourdomain.com/$1 [R=permanent,L]
RedirectMatch 301 ^/subfolder/$
http://www.yourdomain.com/alpha/beta/pie/
Re: Help on 301 Redirect to Avoid Google Problems
Posted: Wed Oct 26, 2011 6:34 pm
by JoaniesGifts
Thanks for your help Avvici , this is all totally alien to me...
So would this work?
RewriteEngine on
RewriteCond %{HTTP_HOST} ^joaniesgifts.co.uk
RewriteRule ^(.*)$
http://www.joaniesgifts.co.uk/$1 [R=permanent,L]
RedirectMatch 301 ^/subfolder/$
http://www.joaniesgifts.co.uk/store/
So if for example a user/google tries to visit
http://www.joaniesgifts.co.uk/store/east-of-india they will be 301 redirected to
http://www.joaniesgifts.co.uk/eat-of-india
Kind Regards,
Joan
Re: Help on 301 Redirect to Avoid Google Problems
Posted: Wed Oct 26, 2011 6:52 pm
by uksitebuilder
try this instead
Code: Select all
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^store/(.*)$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Re: Help on 301 Redirect to Avoid Google Problems
Posted: Wed Oct 26, 2011 9:20 pm
by JoaniesGifts
Thanks so much Simon- looking at that code I could never have figured that out... I will try this tonight in test.
If I implement the 301 this way for the page moves then Google shouldnt hurt my ranking in any way should it? That's my understanding of 301s anyway..
Kind Regards,
Joan
Re: Help on 301 Redirect to Avoid Google Problems
Posted: Wed Oct 26, 2011 9:25 pm
by uksitebuilder
that's correct Joan
better to use 301 - the ranking should follow to the page's new locations
Re: Help on 301 Redirect to Avoid Google Problems
Posted: Thu Oct 27, 2011 2:59 am
by JoaniesGifts
uksitebuilder wrote:try this instead
Code: Select all
1 RewriteCond %{HTTP_HOST} !^www\.
2 RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
3 RewriteRule ^store/(.*)$ /$1 [R=301,L]
4 RewriteCond %{REQUEST_FILENAME} !-f
5 RewriteCond %{REQUEST_FILENAME} !-d
6 RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Hi Simon,
Bits of this work on my test server and bits of it don't. I'm using Xampp and my test domain is
http://localhost
Can i just confirm with you what each of the above lines mean? If I just use the ^store line that seems to work by the way so thanks
I've numbered the lines to make it easier..
Kind Regards,
Joan
Re: Help on 301 Redirect to Avoid Google Problems
Posted: Thu Oct 27, 2011 3:27 am
by uksitebuilder
Hi Joan
OK, so the first two lines make sure that the address starts with www. and if it doesn't it redirects so that it is www.
Line 3 checks if store is at the beginning of the path (after the domain) and if it is it redirects to /
The last three lines are default OC which (4) check if the request is for a real file and (5) if the request is for a real directory (folder) - if not then line 6 pushes the request to index.php which deals with the rewriting etc
it would be those first 2 lines which wont work on your localhost - probably trying to redirect to
www.localhost
Re: Help on 301 Redirect to Avoid Google Problems
Posted: Thu Oct 27, 2011 3:51 am
by JoaniesGifts
Hi Simon,
You've been a great help - thank you so much!
Somebody privated messaged me also asking about this so I think this has helped others too!
I'll hopefully be pushing this all live over the weekend :-)
Kind Regards,
Joan
Re: Help on 301 Redirect to Avoid Google Problems
Posted: Tue Nov 08, 2011 12:53 am
by PinkPearl
uksitebuilder wrote:try this instead
Code: Select all
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^store/(.*)$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Hi Simon, my problem is similar to, but not exactly the same, as Joan's. I have OpenCart in the public_html directory, so no issue with /store. However, I do know that I have URLs with and without the "www" and with and without the "/index.php" and with and without the "https" all going to the Home Page. Could you help me with the code so that they all resolve to
http://www.mystore.co.uk please?
Thank you so much.
Regards,
Chris.
Re: Help on 301 Redirect to Avoid Google Problems
Posted: Tue Nov 08, 2011 2:26 am
by uksitebuilder
Try the following, but please check that your true SSL pages work afterwards as well as other pages
Code: Select all
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/index\.php$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{REQUEST_URI} ^/index\.php$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Re: Help on 301 Redirect to Avoid Google Problems
Posted: Tue Nov 08, 2011 2:47 am
by PinkPearl
Thanks Simon, I'll try that. Do I leave this line:
RewriteRule sitemap.xml /index.php?route=feed/google_sitemap
where it is?
Re: Help on 301 Redirect to Avoid Google Problems
Posted: Tue Nov 08, 2011 3:23 am
by uksitebuilder
You can do, that line is fine
Re: Help on 301 Redirect to Avoid Google Problems
Posted: Tue Nov 08, 2011 4:38 am
by JoaniesGifts
Hi Simon,
I had one more question about this as i've been researching link building.
In the htaccess file I have the line "RewriteBase /"
Is this the command that is automatically adding a "/" to
http://www.joaniesgifts.co.uk ?
I wanted to check that this won't affect links to my website by using
http://www.joaniesgifts.co.uk (without the slash)..(from a google link juice point of view).
Kind Regards,
Joan
Re: Help on 301 Redirect to Avoid Google Problems
Posted: Tue Nov 08, 2011 5:56 am
by PinkPearl
uksitebuilder wrote:Try the following, but please check that your true SSL pages work afterwards as well as other pages
Code: Select all
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/index\.php$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{REQUEST_URI} ^/index\.php$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Unfortunately this doesn't work for me. Having looked more closely at the SSL - it is a shared SSL provided by my hosting company and the https URL doesn't have the www. so trying to force the www. means the secure pages don't work. In these circumstances do you think maybe I should re-direct to the non www. URL instead? If so, could you help?
Another problem I have just found since linking to the SSL, is that when maintenance mode is on, the Store Front link in the admin panel doesn't open the store front but just shows the down for maintenance message. Have you any idea why this should be? I have tested this by restoring the config.php files to what they were originally and the Store Front link works then.
I would appreciate any advice you may have.
Kind regards,
Chris.
Help on 301 Redirect to Avoid Google Problems
Posted: Tue Nov 08, 2011 6:20 am
by uksitebuilder
OpenCart doesn't support Shared SSL by default
You will either need to get a full SSL to match your domain or get an extension to make it work
Maintenance mode will only work for admin where the domain matches
Re: Help on 301 Redirect to Avoid Google Problems
Posted: Tue Nov 08, 2011 6:23 am
by PinkPearl
uksitebuilder wrote:OpenCart doesn't support Shared SSL by default
You will either need to get a full SSL to match your domain or get an extension to make it work
Maintenance mode will only work for admin where the domain matches
Ok thanks. I was just trying to avoid more expense. My host only supports SSL certificates that they sell. Mind you they're not too dear.
Regards,
Chris.
Help on 301 Redirect to Avoid Google Problems
Posted: Tue Nov 08, 2011 6:23 am
by uksitebuilder
skyfirexl wrote:Hi Simon,
I had one more question about this as i've been researching link building.
In the htaccess file I have the line "RewriteBase /"
Is this the command that is automatically adding a "/" to
http://www.joaniesgifts.co.uk ?
I wanted to check that this won't affect links to my website by using
http://www.joaniesgifts.co.uk (without the slash)..(from a google link juice point of view).
Kind Regards,
Joan
I believe it just serves as a base telling the mod_rewrite module where to start rewriting from relative to the domain root
Re: Help on 301 Redirect to Avoid Google Problems
Posted: Tue Nov 08, 2011 6:55 am
by PinkPearl
Help! I've lost my add to cart buttons. Could it be anything to do with all of the above? Although I'm pretty certain I've restored all the files to original form. (There seems to be a missing "review" image as well.
Thanks
Re: Help on 301 Redirect to Avoid Google Problems
Posted: Tue Nov 08, 2011 5:06 pm
by uksitebuilder
How are your config.php and admin/config.php files set-up ?