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”
- Create a new file in your favorite editing program. Notepad is an easy choice.
- Paste the following:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursitenamehere.com [NC]
RewriteRule ^(.*)$ http://www.yoursitenamehere.com/$1 [L,R=301] - Save the file as .htaccess
- Upload to your server
- Test by going to yoursitenamehere.com. This should redirect you to the URL www.yoursitenamehere.co
- 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”