Skip to content
WJunction - Webmaster Forum

Redirect non-www to www and vice versa

Status
Not open for further replies.
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)
 
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.
used this on ddl0.com, works perfectly.
thanks :)
 
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.

About the author

I
Active Member · Joined
1,001
Messages
18
Reactions
38
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom