summaryrefslogtreecommitdiff
path: root/apache2/conf-available/local-html5-www-add.conf
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2016-04-17 10:53:56 +0200
committerJonas Smedegaard <dr@jones.dk>2016-04-17 10:53:56 +0200
commit1eb364f42804fb04daefb8b34ca42b2cc7cc39fa (patch)
treea1ef714581a1cecce6937c32ca9e71163aa345ee /apache2/conf-available/local-html5-www-add.conf
parent64dc2dd8e6b275afee366a94c01ee800a43d94d5 (diff)
Separate snippets for adding/stripping www.
Diffstat (limited to 'apache2/conf-available/local-html5-www-add.conf')
-rw-r--r--apache2/conf-available/local-html5-www-add.conf47
1 files changed, 47 insertions, 0 deletions
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
+
+#<IfModule mod_rewrite.c>
+# RewriteEngine On
+# RewriteCond %{HTTPS} !=on
+# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
+# RewriteRule ^ %{ENV:PROTO}://%1%{REQUEST_URI} [R=301,L]
+#</IfModule>
+
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+# 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.
+
+<IfModule mod_rewrite.c>
+ 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]
+</IfModule>