Jump to content

Recommended Posts

Posted

I notice in .htaccess there is code to redirect to the www version of the site (if you uncomment it), what about vice versa? Because currently you can access the site from either www or no www. Could this be made a selection during install?

  • Like 1
Posted

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
Posted

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

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
×
×
  • Create New...