Friday, August 17, 2012

Updating Google Sitelinks causing some head scratching.-.htaccess redirects, etc.

I implemented a new site that replaced an existing site. The old site had pretty good Google placement and in the search results Google rendered 6 sitelinks. Unfortunatly, none of these pages still exist in the locations that these links point to. I could not find a way to update them in Google Webmaster tools. You can remove them (demote), but I did not see how you can edit them.

My knowledge on the subject is intermediate at best, but I know that the links being broken is terrible, but using simple PHP or META redirects--although better than broken--are bad Google practice. I believe Google will penalize for this. I knew I needed to redirect then links at the server level.

But first I used page-level redirects as a stop-gap since not matter what, I could not have the links broken.

Bring on .htacess.

My first try was to use a 301 redirect. This worked, except that I was redirecting from a directory to a file ( /contact/ >> The problem with this was that it did redirect, but it thought the new location was a directory and added a trailing slash, but broke all the URL paths in the page. The CSS didn't work, the images, didn't show up, etc. I tried to figure out a way to remove the trailing slash in the htaccess file, but I could never get it to work.

What did work was using RedirectMatch:

RedirectMatch 301 ^/contact/

The only catch was that one of the old links was in a sub, sub directory. That redirect didn't work correctly, as it redirected from the parent directory.

RedirectMatch 301 ^/contact/
RedirectMatch 301 ^/contact/sales/

The second redirect resolved to

My only thought is that when the htacess file sees the slash after contact it stops looking at that line and the first line handles the redirect.

I'm still working on that issue.

No comments:

Post a Comment