Jump to content

www or no www


antknight
 Share

Recommended Posts

We force a non-www on processwire.com, but it seems that not many sites do that for whatever reason. If you want to do that, here's the code you can use in your htaccess (replacing processwire.com with your domain):

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

This isn't technically part of ProcessWire's runtime configuration because the rules in the htaccess file are what ultimately gives control to ProcessWire (they are executed before ProcessWire is).

  • Like 2
Link to comment
Share on other sites

This is how html5boilerplate does it. the nice thing is it works without specifying your domainname and could easily included in your own default htaccess:

# Rewrite "www.example.com -> example.com"
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>

https://github.com/h5bp/html5-boilerplate/blob/master/.htaccess#L344

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...