Skip to content

Commit

Permalink
Merge pull request phanan#22 from StyxOfDynamite/master
Browse files Browse the repository at this point in the history
Added generic method for forcing non-www
  • Loading branch information
phanan committed Feb 14, 2015
2 parents 609cbd2 + 7bb2f30 commit c1d5886
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 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)
Expand Down Expand Up @@ -71,6 +72,15 @@ RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
```

### Force non-www in a Generic Way
``` 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
Expand Down

0 comments on commit c1d5886

Please sign in to comment.