Redirect non-www to www and vice versa

Status
Not open for further replies.

iFlames

Active Member
1,001
2009
18
0
To do this edit your .htaccess file in your website root directory.

Add this code at the Top:
Code:
RewriteEngine On
Options +FollowSymLinks

Add this code at the End:
Redirecting non-www to www:
Code:
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
*Replace yourdomain.com with your domain name.

Redirecting www to non-www:
Code:
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
*Replace yourdomain.com with your domain name.


Thats it :)
 
10 comments
[slide]http://www.babble.com/CS/blogs/strollerderby/2009/06/chocolate_chip_cookie.jpg[/slide]

My cookie doesnt taste good, any fix fr tht??

P.S. thnx fr tutorial (y)
 
Great tutorial. You can also set your cookie domain to .example.com in the admincp in vBulletin or if your using a custom script set the cookie domain using PHP or the coding language of choice.
 
Status
Not open for further replies.
Back
Top