301 Redirect – Apache

I would consider this one of the first steps that you should take when establishing a new web site. If you are searching for “301 redirect” you probably already know why. Here is a simple .htaccess file that you can use to do the redirect.  You will also find this referred to as a “mod rewrite”

  1. Create a new file in your favorite editing program. Notepad is an easy choice.
  2. Paste the following:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^yoursitenamehere.com [NC]
    RewriteRule ^(.*)$ http://www.yoursitenamehere.com/$1 [L,R=301]
  3. Save the file as .htaccess
  4. Upload to your server
  5. Test by going to yoursitenamehere.com. This should redirect you to the URL www.yoursitenamehere.co
  6. Check the server header response to be safe. Should return “HTTP/1.1 301 Moved Permanently”

If you are using a web design program like Dreamweaver, it might tell you that it can’t find a valid editor for this extension (it doesn’t have one). Simply right click on the file and select “open using Dreamweaver”. You can also open/edit, in notepad.

If you are on a windows host, you can view the following method to handle an ISAPI rewrite using IIS.

One thought on “301 Redirect – Apache”

Leave a Reply

Your email address will not be published. Required fields are marked *