Redirect from www to non www website

Status
Not open for further replies.

adrianr2z

New Member
Messages
1
Reaction score
0
Points
1
Hey everyone,

Currently addon a seperate domain and I want to be able to redirect someone from going to www.example.com to example.com. What is the best way to do this? I want people to be redirected automatically from the www to the non www version.
 

uraceele

Member
Messages
54
Reaction score
8
Points
8
Htaccess might be your best bet. Put this in .htaccess file in your root directory but you will need to change the domain.
Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

Just a little FYI - Google is everyone's friend. All you had to do was google "redirect www to non www" and you would've found everything you needed...
 
Last edited:

wazza6

Member
Messages
63
Reaction score
0
Points
6
Hey, I know the question has already been answered but I'd like to add that I use this:
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
It's basically a copy-paste thing so you don't have to modify it for your domain. I haven't tested it but if you have multiple domains it should work too.
 

uraceele

Member
Messages
54
Reaction score
8
Points
8
Hey, I know the question has already been answered but I'd like to add that I use this:
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
It's basically a copy-paste thing so you don't have to modify it for your domain. I haven't tested it but if you have multiple domains it should work too.
Yes, I am aware. There's many configurations. I myself have something similar but I have to deal with https as well... I was just hoping my reply would get him to research it himself and find the best applicable solution but thanks for ruining that! lol
 
Status
Not open for further replies.
Top