Admin Life Errors, Fixes, and Encounters

18Jan/10Off

domain redirect .htaccess

To redirect one domain to another or even to redirect a domain to add www at the beginning of website address you'll need to do a few things.

1) Create an .htaccess file in the main directory of the website (document root)

2) add the following code inside .htaccess and change line 3 and 4.
line 3: current domain(website) to find
line 4: redirect domain(website)

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

That's it! If it doesn't work make sure in your httpd.conf (apache only) that AllowOverride is set to "AllowOverride ALL" and not "AllowOverride None"

Here's a sample

AllowOverride ALL

That can also be put inside for domain specific settings.