Using .htaccess To Redirect Visitors and Search Engines

December 29, 2007 – 12:01 pm

So I learned something new today. I’ve had this blog at http://robert.arlesnet.com for quite a while, but also had a site I never updated at http://www.arlesnet.com. I had finally decided it made more sense to have all “arlesnet.com” visitors end up at my blog rather than some unmaintained site. I put the code below in the .htaccess file at arlesnet.com. The actual directory location will vary per server, but is often something like a public_html or www directory. As a clue, it should be in the same place as the index file for the site you are trying to redirect.  Also note that files starting with a dot are ‘hidden’ in *nix…


Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} arlesnet.com$
RewriteRule ^(.*)$ http://robert.arlesnet.com/$1 [R=301,L]

If you want to use this for your own site, all you need to change is the domain info in the 3rd and 4th lines.  Line 3 is has the domain name you want to capture.  Line 4 is where you want the visitor or search engine to be directed to.  The ‘R=301′ sets this to be a permanent change.   Presumably, search engines will get the hint.

Post a Comment