From 5af99d891db331d2f97c2ad9af26c0fd091d92ce Mon Sep 17 00:00:00 2001 From: Luke Storer Date: Thu, 12 Feb 2015 17:53:02 +0000 Subject: [PATCH 1/3] [feature] added generic method for forcing non-www whilst keeping the current protocol intact --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index fb6e5a2..10b76cf 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ What I'm doing here is mostly collecting useful snippets from all over the inter - [Force www](#force-www) - [Force www in a Generic Way](#force-www-in-a-generic-way) - [Force non-www](#force-non-www) + - [Force non-www (preserve protocol)](#force-non-www-keep-protocol) - [Force HTTPS](#force-https) - [Force HTTPS Behind a Proxy](#force-https-behind-a-proxy) - [Force Trailing Slash](#force-trailing-slash) @@ -71,6 +72,15 @@ RewriteCond %{HTTP_HOST} ^www\.example\.com [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301] ``` +### Force non-www whilst keeping the current protocol (http:// or https://) +``` apacheconf +RewriteEngine on +RewriteCond %{HTTP_HOST} ^www\. +RewriteCond %{HTTPS}s ^on(s)|off +RewriteCond http%1://%{HTTP_HOST} ^(https?://)(www\.)?(.+)$ +RewriteRule ^ %1%3%{REQUEST_URI} [R=301,L] +``` + ### Force HTTPS ``` apacheconf RewriteEngine on From 20ebc58bc23ee5b27f4e2d9d6434d076b331c163 Mon Sep 17 00:00:00 2001 From: Luke Storer Date: Thu, 12 Feb 2015 17:57:27 +0000 Subject: [PATCH 2/3] [bug] fixed markup to include relative link from table of contents to snippet --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 10b76cf..ea2dcc7 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ What I'm doing here is mostly collecting useful snippets from all over the inter - [Force www](#force-www) - [Force www in a Generic Way](#force-www-in-a-generic-way) - [Force non-www](#force-non-www) - - [Force non-www (preserve protocol)](#force-non-www-keep-protocol) + - [Force non-www in a generic way](#force-non-www-in-a-generic-way) - [Force HTTPS](#force-https) - [Force HTTPS Behind a Proxy](#force-https-behind-a-proxy) - [Force Trailing Slash](#force-trailing-slash) @@ -72,7 +72,7 @@ RewriteCond %{HTTP_HOST} ^www\.example\.com [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301] ``` -### Force non-www whilst keeping the current protocol (http:// or https://) +### Force non-www in a Generic Way ``` apacheconf RewriteEngine on RewriteCond %{HTTP_HOST} ^www\. From 7bb2f300d78eb4de5de8ace03836ab8fdff14321 Mon Sep 17 00:00:00 2001 From: Luke Storer Date: Fri, 13 Feb 2015 11:22:30 +0000 Subject: [PATCH 3/3] [bug] coorected section header in table of contents to use title case --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ea2dcc7..9604a3c 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ What I'm doing here is mostly collecting useful snippets from all over the inter - [Force www](#force-www) - [Force www in a Generic Way](#force-www-in-a-generic-way) - [Force non-www](#force-non-www) - - [Force non-www in a generic way](#force-non-www-in-a-generic-way) + - [Force non-www in a Generic Way](#force-non-www-in-a-generic-way) - [Force HTTPS](#force-https) - [Force HTTPS Behind a Proxy](#force-https-behind-a-proxy) - [Force Trailing Slash](#force-trailing-slash)