www to non www? how?

peter73

Regular Member
Joined
Jun 27, 2010
Messages
337
Reaction score
90
Hi, I searched all over google but all the tutorials only teach you to redirect from non www to www
Can someone please help me on what I will put on the .htaccess file?

I don't want my site to have the www So I've been trying to figure out how to redirect from www to non www

Thanks for the help
 
If you have hosting with cpanel, you can do it in there without the need for htaccess
 
Redirect www to non-www:
<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteCond %{HTTP_HOST} ^http://www.yourdomain.com [NC]RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]</IfModule>
Redirect non-www to www:
<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]</IfModule>
 
I already tried that, but there is some error popping up in firefox. Thanks anyway I managed to change now.
 
Back
Top