Forum Moderators: phranque

Message Too Old, No Replies

Google has Cached the "old" SEO Unfriendly Link . . . ?

         

atombomb12

1:54 pm on Apr 13, 2009 (gmt 0)

10+ Year Member



Hi Everyone,
My brain is on meltdown. I can program in php a fair bit, but .htaccess is a monster that needs taming, phew!

I have a rewrite issue that I just can't solve despite spending some looooong nights trying out different things. I'll put it as a 1, 2, 3 as it helps me think clearer too. :-)

This issue is:

1) I put up a site that has the URL format for a product detail page (coming from a datafeed) of [mysite.com...]

2) I got the rewrite going properly, so it rewrites to the format
[mysite.com...]

3) The problem is, Google has spidered and indexed lots and lots of the old format links
e.g.

[mysite.com...]
[mysite.com...]
[mysite.com...]

since I put the friendly URL's into place.

4) I just need to "tell" Google that these format pages haved "moved" with a 301 redirect, as I am worried about a Google duplicate content penalty and Google thinking that there are 2 identical pages (apart from the URL).

How can I tell google to do a 301 on the old format links of [mysite.com...] and send them either to the homepage, or to the friendly URL ?

5) Many thanks for reading, much appreciated. If any gurus can help me, I would be much appreciated.

This is what is in the .htaccess at the moment:

#RewriteRule product-(.*)-(.*)\.html$ product.php?%{QUERY_STRING}
RewriteRule (.*)-p-(.*).html$ product.php?p=$2%{QUERY_STRING}
RewriteRule (.*)-pname-(.*).html$ product.php?p=$2&showsort=pname%{QUERY_STRING}
RewriteRule (.*)-mname-(.*).html$ product.php?p=$2&showsort=mname%{QUERY_STRING}
RewriteRule (.*)-price-(.*).html$ product.php?p=$2&showsort=price%{QUERY_STRING}

#rewriterule ^product.php$ [mysite.com...] [r=301,L]

Thanks everyone,
Best Regards,
Paul

redhatlab

4:34 pm on Apr 13, 2009 (gmt 0)

10+ Year Member



Hi atombomb12,

I think as a quick alternative you can add a line of code to product.php to check if only the "p" variable is on use and all others are empty then the url is like:

[mysite.com...]

The you can issue a redirection using the header function from PHP and you can even issue a 301 before redirecting.

g1smd

5:00 pm on Apr 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Your rewrite rules have a LOT of flaws. Firstly add [L] the end of every one.

Next. The .* pattern is extremely inefficient as the first matches the whole URL and then had to back-off-and-retry hundreds of matches before a match is found. You need a more specific pattern here.

Additionally, your site is open to trickery from competitors. You link to

www.example.com/this-is-the-product-name-p-329744.html
and your competitors link to
www.example.com/this-product-is-dangerous-junk-p-329744.html
. Your script *must* do a lookup (using the product number as database key) of the keyword part and verify that it matches the product number. For wrong words the script must send a 301 redirect to the correctly worded URL. For non-valid product number the script must return a 404 HTTP header.

.

Finally, to your question... you need your script to return a 301 redirect to the correct URL for that content. This cannot be achieved in .htaccess - your script must do it. This is because the script will need to look in your database to get the "words tom insert into the friendly URL".

There was a very similar question a few weeks ago. Please read all of the answer there [webmasterworld.com...] rather than have me repeat it all again here.

atombomb12

6:04 pm on Apr 13, 2009 (gmt 0)

10+ Year Member



Hi Redhatlab and g1smd,
Thanks a lot for your *amazingly* fast replies and taking the time to answer, it is much appreciated. :-)

I'll dig through the other thread and read up, thanks once again.

Best Regards,
Paul