# Apache Server Configs v2.14.0 | MIT License # https://github.com/h5bp/server-configs-apache # ---------------------------------------------------------------------- # | Suppressing / Forcing the `www.` at the beginning of URLs | # ---------------------------------------------------------------------- # The same content should never be available under two different # URLs, especially not with and without `www.` at the beginning. # This can cause SEO problems (duplicate content), and therefore, # you should choose one of the alternatives and redirect the other # one. # # By default `Option 1` (no `www.`) is activated. # http://no-www.org/faq.php?q=class_b # # If you would prefer to use `Option 2`, just comment out all the # lines from `Option 1` and uncomment the ones from `Option 2`. # # (!) NEVER USE BOTH RULES AT THE SAME TIME! # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Option 1: rewrite www.example.com → example.com # # RewriteEngine On # RewriteCond %{HTTPS} !=on # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] # RewriteRule ^ %{ENV:PROTO}://%1%{REQUEST_URI} [R=301,L] # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Option 2: rewrite example.com → www.example.com # # Be aware that the following might not be a good idea if you use "real" # subdomains for certain parts of your website. RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{SERVER_ADDR} !=127.0.0.1 RewriteCond %{SERVER_ADDR} !=::1 RewriteRule ^ %{ENV:PROTO}://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]