我真的很纠结于.htaccess规则。我真的不明白它是如何工作的......我的代码有什么问题。我在随机测试多种变化,却无法理解我的问题从何而来。
我希望有以下规则。
所有的httpwwwnon-www都指向同一个地方 https:/www 网址。
其他https子域。
我域名的关键页面的URL重写。
我的网站允许用户在xxx.example.com下创建自己的页面。
通过我的主机服务(BlueHost)创建的 "子域名 "可能会有一些冲突。
子域 - 根域 - 文件根 - 重定向。
(star) - .example.com - public_htmlevent - 未被重定向。
blog - .example.com - public_htmlblog - not redirected -------。
static - .example.com - public_htmlstatic - 未被重定向。
我也有一个CNAME配置.....:
主机记录 -指向 -TTL
www - example.com - 14400
我现在的.htaccess:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?example.com [NC]
RewriteRule (.*) https://www.example.com [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(static|blog)\.example\.com [NC]
RewriteRule .? https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_URI} =/overview
RewriteRule ^ /page.php?id=overview [L]
RewriteCond %{REQUEST_URI} =/faq
RewriteRule ^ /page.php?id=faq [L]
(few more pages like that..)
有很多问题
http:/ blog.example.com没有重定向到https版本(但奇怪的是......'http:/ static...'却重定向到了https)。
http:/ www.example.com?param=123: '?param=123'是'跳过'。我试过添加'QSA'标志......但也不行。
(抱歉,无法提供所有httphttpswwwnon-www的使用案例--StackOverflow认为这是一个垃圾邮件)
我真的不知道从哪里开始解决这个问题......1000谢谢你的帮助!
ThanksDamien。
添加这个重写规则的http到https重定向和测试。
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
使用下面的规则附加'?param=123'。
RewriteCond %{HTTP_HOST} ^(www\.)?example.com$ [NC]
RewriteRule (.*) https://www.example.com$1 [R=301,L]