August 13th, 2012 Add Your Comments Bookmark and Share

I think we can all agree that 301 redirecting an entire domain to a new one isn’t going to solve your Google penalty issues. However, what happens if you were running a small’ish website and you’ve maybe only been over aggresive with the linking to one or two pages? You could 301 redirect the old domain to a new one for all except those pages…if only you knew how to do it.

If this sounds like you and you are sure you’ve only got a couple of pages that are causing your Google penalty issues then you can try redirecting all except your problem pages. Here is how to do that with your .htaccess file.

RewriteEngine on
RewriteCond $1 !^page-not-to-redirect.html
RewriteCond $1 !^404.shtml
RewriteRule (.*)$1 [R=301,L]

It’s fairly easy to understand. The first line turns the rewrite engine on, the second line after !^ is the URL of the page you don’t want to redirect, the third line tells the server not to redirect any request for 404 not found page* and finally the 4th line does the redirection to the new domain. Simple but effective.

* You need this because if the page you DON’T want redirecting no longer exists under the old domain the server will then look for a 404 error document to show. Of course if you don’t include this in your list of exclusions then the redirection will kick in and the visitor will be greated with a 404 error from your new domain. The actual 404 page the server tries to serve up may depend on your server configuration or content management system but trying to surf to a non existent page on your old penalised domain should let you know what it wants to serve up (404.shtml in the example above).