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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

How to Redirect WWW to Non-WWW with htacess


Go to End


3 Posts   2187 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
(deleted)

Community Member, 473 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.