...

View Full Version : rewrite www to non-www



Mayhem30
04-11-2010, 11: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)

Thanks!

DJCMBear
04-12-2010, 03: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]

Techmafia.org
04-14-2010, 05: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]

Mayhem30
04-14-2010, 07:59 PM
Thanks guys!

sentril
04-18-2010, 05: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