Sunday, February 28, 2010

.htaccess file 301 redirect - to avoid duplicate content

Ya - I'm an ASP.net programmer, but every now and then I do a bit of php or other maitenance..

The other day I had to update a website for SEO. I noticed that this guy had two domains pointed to the same website... and that you can crawl them exactly the same.

Unfortunately, this gets a duplicate content penalty so I had to update the .htaccess file to correct this and do 301 redirects. Here are the lines of code needed to do this if you ever need it:

RewriteCond %{HTTP_HOST} ^^(www\.)?dontneedthis\.com$ [NC]
RewriteRule ^(.*)$ http://www.spiderweblogic.com/$1 [R=301,L]


Of course - change spiderweblogic to your website...

TIP: don't kill any existing .htaccess file. Just append this code towards the top. (You may not see it if you use a ftp program.)

No comments:

Post a Comment