From 1eb364f42804fb04daefb8b34ca42b2cc7cc39fa Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sun, 17 Apr 2016 10:53:56 +0200 Subject: Separate snippets for adding/stripping www. --- apache2/conf-available/local-html5-www-add.conf | 47 +++++++++++++++++++++++ apache2/conf-available/local-html5-www-strip.conf | 47 +++++++++++++++++++++++ apache2/conf-available/local-html5.conf | 41 +------------------- 3 files changed, 95 insertions(+), 40 deletions(-) create mode 100644 apache2/conf-available/local-html5-www-add.conf create mode 100644 apache2/conf-available/local-html5-www-strip.conf diff --git a/apache2/conf-available/local-html5-www-add.conf b/apache2/conf-available/local-html5-www-add.conf new file mode 100644 index 0000000..c7a9fb8 --- /dev/null +++ b/apache2/conf-available/local-html5-www-add.conf @@ -0,0 +1,47 @@ +# 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] + diff --git a/apache2/conf-available/local-html5-www-strip.conf b/apache2/conf-available/local-html5-www-strip.conf new file mode 100644 index 0000000..dd79991 --- /dev/null +++ b/apache2/conf-available/local-html5-www-strip.conf @@ -0,0 +1,47 @@ +# 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] +# diff --git a/apache2/conf-available/local-html5.conf b/apache2/conf-available/local-html5.conf index cc490bf..aedc96a 100644 --- a/apache2/conf-available/local-html5.conf +++ b/apache2/conf-available/local-html5.conf @@ -359,46 +359,7 @@ AddDefaultCharset utf-8 # | 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] -# +# (moved to separate snippets) # ###################################################################### -- cgit v1.2.3