Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

How to Redirect WWW to Non-WWW with htacess


Reply


3 Posts   1644 Views

Avatar
socks

Community Member, 191 Posts

26 October 2008 at 9:33am

Edited: 26/10/2008 9:36am

I usually do this in the htacess:

RewriteCond %{http_host} ^www.mywebsite.com/ [NC]
RewriteRule ^(.*)$ http://mywebsite.com/$1 [R=301,NC]

but it isn't working. Any suggestions?

thanks,
Clint

Avatar
simon_w

Forum Moderator, 474 Posts

26 October 2008 at 10:48am

Edited: 26/10/2008 10:52am

RewriteCond %{HTTP_HOST} ^www.simon.geek.nz$
RewriteRule ^(.*)$ http://simon.geek.nz/$1 [R=301,L]

Works fine for me. Note, there's no trailing slash on the domain name, which appears to be your problem.

Avatar
socks

Community Member, 191 Posts

26 October 2008 at 11:04am

I changed the "/" to a "$" and I also had to specify the RewriteRule as the Last rule with the "L".

Thanks for your help.