1
我萃取下面的代码从这里在计算器(Enforce www and trailing slash with mod_rewrite htaccess on a multi-domain site)问题,并直接从apache.org。MOD-重写/重写规则:强制的https:// WWW作为协议和域
的情况下由三个要求:
- 保证,是生产域以www总是启动。
- 不追加WWW。到beta.domain.tld,dev.domain.tld,mobile.domain.tld
- 终于保证,每一个URL获取改写为https。
我想出了以下条件:
# Enforce www, if no subdomain is given
RewriteCond %{HTTP_HOST} !^(beta|dev|mobile|www)\.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI}/ [R]
# Enfore SSL for all Domains
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
所提到的规则按预期工作,虽然一个单一的情况下不能正常工作:
https://domain.tld/没有正确重定向到https://www.domain.tld/
有人能帮助我吗?
THX对于这一点,就像一个风情万种! –
不客气,很高兴它的工作。 – anubhava