【发布时间】:2016-07-05 22:46:06
【问题描述】:
以下重写规则在我独立使用时有效。但是他们一起忽略了改变根。我想:
- 强制 https
- 强制非www
- 有一个子目录
/live成为域根
服务器是这样的:
/
/dev
/live
htaccess 是这样的:
RewriteEngine On
# Rewrite /live to root
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule !^live/ /live%{REQUEST_URI} [L]
# Remove www + force https
RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]
这应该发生:
http://example.com -> https://example.com
http://www.example.com -> https://example.com
https://www.example.com -> https://example.com
但是会发生这种情况:
http://example.com -> https://example.com/live
http://www.example.com -> https://example.com/live
https://www.example.com -> https://example.com/live
如果有人建议如何使用这两个规则,那就太好了,我不想将我的网站内容移动到我服务器上的根目录中。
谢谢
【问题讨论】:
标签: .htaccess redirect https rewrite subdirectory