mirror of
https://github.com/phanan/htaccess.git
synced 2018-11-08 13:39:40 +01:00
[feature] added generic method for forcing non-www whilst keeping the current protocol intact
This commit is contained in:
parent
40d5fc7ded
commit
5af99d891d
1 changed files with 10 additions and 0 deletions
10
README.md
10
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
|
||||
|
|
Loading…
Reference in a new issue