View Full Version : rewrite www to non-www

04-11-2010, 10:11 PM
Could someone please let me know the proper way to do a 301 redirect from www.example.com -> example.com?

This is for Apache 2.2.x using vhosts (not .htaccess)


04-12-2010, 02:57 AM
I'm not 100% on vhosts but give this ago hopefully this will work.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(([^.]+\.)+([^.]+))
RewriteRule ^/(.*)$ [%1...] [R=301,L]

04-14-2010, 04:29 PM
its called to force no-www if i am write

you can use this

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC,L]

04-14-2010, 06:59 PM
Thanks guys!

04-18-2010, 04:23 PM
One other thing, it took me a day to figure this out. I had the same issue and had this command in my htaccess file but it wasn't taking it. I went to the httpd.conf file and changed the override command to all instead of none. Restarted the server and voila, it worked.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum