Post by jcgadgets » Fri Jan 21, 2011 4:36 am

I've recently changed all of my product and category URL's (what a NIGHTMARE even for just ten products and four categories). The word "buy" is a very big keyword for my products, so I really needed to integrate that.
While I've already removed them from Google and blocked them in robots.txt, I need to redirect them while they still show up in search results.

At the beginning of my file I have:

Code: Select all

RewriteEngine On
RewriteBase /StoreFront/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
I've attempted the following entries for a particular product, but neither seem to work:

Code: Select all

RewriteCond %{QUERY_STRING} http://domain/StoreFront/Apple-MacBook-MC024LLA$
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteRule ^index\.php$ http://domain/StoreFront/Buy-MacBook/Buy-MacBookPro-MC024LLA? [R=301,L]

Code: Select all

RewriteCond %{QUERY_STRING} ^Apple-MacBook-MC024LLA$
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteRule ^index\.php$ http://domain/StoreFront/Buy-MacBook/Buy-MacBookPro-MC024LLA? [R=301,L]
I've been able to successfully redirect pages who's URL's start with route= before, but I don't know how to redirect an already SEO'd URL? Any suggestions? I'm just not sure what to put for query string...


Thank you,
Jared

Active Member

Posts

Joined
Sun Oct 31, 2010 4:49 pm

Post by Chones » Fri Jan 21, 2011 5:14 am

For that, I wouldn't use mod_rewrite. For 10 products, that's when it's best to use 301 redirects. That's what it is for.

When you change a URL, always use 301 redirect.

Mod_rewrite is for changing things like &product_id=24 to /product-name

http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by jcgadgets » Fri Jan 21, 2011 5:42 am

Craig,

Thanks again. I guess I must be even more confused about all of this than I thought. I thought that the above code did indeed perform a 301 redirect, as per the [R=301,L] text at the end?

All of my redirects have been done by using the code in my last post. Are those sort of redirects bad for SEO?

In your example of changing &product_id=24 to /product-name, I've always been taking the whole URL. Example:
domain/StoreFront&product_id=24
redirects to:
domain/StoreFront/product-name

Instead of the above, should I only have:
*&product_id=24
redirects to:
*product-name

Or something, changing only the end of the URL rather than the whole path?

Confused :S


Thank you,
Jared

Active Member

Posts

Joined
Sun Oct 31, 2010 4:49 pm

Post by Chones » Fri Jan 21, 2011 6:33 am

Sorry, wasn't concentrating, didn't see the R=301. I always use this - much simpler:

Code: Select all

redirect 301 /StoreFront/old http://domain/StoreFront/new
So you could try

Code: Select all

redirect 301 /StoreFront/Apple-MacBook-MC024LLA http://domain/StoreFront/Buy-MacBook/Buy-MacBookPro-MC024LLA
The example of &product_id=24 to /product-name - that is about how OpenCart coverts URLs to SEO Urls using the SEO keyword - you don't have to do anything. In fact, forget I said anything about that - I've had a long day :-\

http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by Chones » Fri Jan 21, 2011 6:42 am

Although if no one is linking to the URL just change it and remove the old one from Google.

http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by jcgadgets » Fri Jan 21, 2011 7:20 am

Ha, ok - I must admit I got a little confused through there.

What I did get was that I can use the different coding for redirects.

I have input:
redirect 301 /StoreFront/Apple-MacBook-MC024LLA http://domain/StoreFront/Buy-MacBook/Bu ... k-MC024LLA

What I get:
http://domain/StoreFront/Buy-MacBook/Bu ... k-MC024LLA

...which is a "The page you requested cannot be found!" OpenCart page.

Any ideas?

Thank you,
Jared

Active Member

Posts

Joined
Sun Oct 31, 2010 4:49 pm

Post by jcgadgets » Tue Jan 25, 2011 3:57 pm

Hey there Craig (or anyone else),

I was just wondering if I might bug you a bit for how to polish off this particular part? I feel like I've almost got it, but for some reason the URL just gets a little screwed up along the way...


Any help appreciated!
Thanks,
Jared

Active Member

Posts

Joined
Sun Oct 31, 2010 4:49 pm

Post by Chones » Thu Jan 27, 2011 4:15 am

Ah, it looks like a problem with 301 and the RewriteEngine. You should try this.
http://forum.opencart.com/viewtopic.php?f=20&t=24877

http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by jcgadgets » Thu Jan 27, 2011 2:38 pm

Hey thanks a lot! The ? at the end did the trick. The URL itself does keep the ?, which I don't care for...but it's better than a "page not found"!


Thank you,
Jared

Active Member

Posts

Joined
Sun Oct 31, 2010 4:49 pm
Who is online

Users browsing this forum: No registered users and 109 guests