SEO Resources - Frequently Asked Questions
How do I Setup a .htaccess File for Redirection?
![]()
There are various reasons why .htaccess files are useful for Webmasters - especially when it comes to Search Engine Optimization. For some users these files might seem a bit complicated, but they are actually pretty simple.
There are two common uses for .htaccess files that are quite simple to set up. Their instructions are below. The essential way to create an .htaccess file is to create a new document in a simple text editor (MS Notepad, for example). The code provided in the examples below (with your own domain substituted for the example, of course) is all that the file needs to contain. When this code has been added to the document you need to save the document as ".htaccess." Ignore all warnings that this is not a recognized extension for your operating system - it is recognized by your server. Please note: .htaccess files can only be used on Linux servers that have the Apache Mod-Rewrite module enabled.
REDIRECT AN OLD DOMAIN TO A NEW DOMAIN
Adding the following code to your .htaccess file will ensure that your directories and pages of your old domain will redirect to your new domain. The .htaccess file needs to be included in the root directory of the old domain.
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301, L] Replace "www.newdomain.com" in the code above with the new domain name you have moved to.
REDIRECT TO WWW.
Sometimes you want, for a variety of possible reasons, to redirect users who have attempted to access your domain without the "www." prefix to the URL including that prefix. This might be for security reasons (if your site uses an SSL certificate) or otherwise. Creating an .htaccess file with the code below will ensure this redirection. Again, this .htaccess file needs to be in the root directory of your website.
Options +FollowSymLinks
RewriteEngine on
rewritecond %{http_host} ^domain.com[nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]




