想要实现的需求:
求大神指点
1
lslqtz 2017-02-28 13:07:46 +08:00 via iPhone
|
3
hqfzone 2017-03-01 16:27:46 +08:00 1
RewriteCond %{SERVER_PORT} !^443$ [OR]
RewriteCond %{HTTP_HOST} !^example.com$ [NC] RewriteRule "^/?(.*)" "https://example.com/$1" [L,R=301] |
4
Totato5749 OP |
5
lslqtz 2017-03-02 22:06:46 +08:00
@hqfzone
@Totato5749 RewriteCond %{SERVER_PORT} !^443$ RewriteCond %{HTTP_HOST} !^example.com$ [NC] RewriteRule "^/?(.*)" "https://example.com/$1" [L,R=301] 这个呢? |
6
lslqtz 2017-03-02 22:09:31 +08:00
抱歉,我也写错了。。
|
7
lslqtz 2017-03-02 22:12:03 +08:00
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_HOST} !^example.com$ [NC] RewriteRule ^(.*)$ https://example.com/$1 [L,R=301] 好吧 刚刚那个似乎没问题 |
8
lslqtz 2017-03-02 22:14:36 +08:00
是我写错了。。
改成这样吧: RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^(.*)$ https://example.com/$1 [L,R=301] RewriteCond %{HTTP_HOST} !^example.com$ [NC] RewriteRule ^(.*)$ https://example.com/$1 [L,R=301] |
10
Totato5749 OP |
11
hqfzone 2017-03-03 16:28:06 +08:00
@Totato5749 具体情况不了解,问题解决了就行吧……
|
12
Totato5749 OP @hqfzone 问题没解决= = 因为会无限重定向,网站进不去
|
14
lslqtz 2017-03-03 16:47:21 +08:00
@Totato5749 其他的 htaccess 呢
|
15
Totato5749 OP @lslqtz
我现在的 htaccess 是网上找的,不过是全部跳转到带 www 的 https 地址,我是不想要 www 来着。。 RewriteEngine on RewriteCond %{HTTP:KERSSL} !on RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteCond %{HTTP_USER_AGENT} !MSIE/[1-8]\. [NC] RewriteRule ^(.*)$ https://www.example.com/$1 [R=301] RewriteCond %{HTTP:KERSSL} on RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteCond %{HTTP_USER_AGENT} !MSIE/[1-8]\. [NC] RewriteRule ^(.*)$ https://www.example.com/$1 [R=301] RewriteCond %{HTTP:KERSSL} !on RewriteCond %{HTTP_HOST} ^www.example.com [NC] RewriteCond %{HTTP_USER_AGENT} !MSIE/[1-8]\. [NC] RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L] |
16
lslqtz 2017-03-03 17:05:58 +08:00
@Totato5749 那你不会之前的没删就加上去了吧。。
你自己不会改吗? RewriteEngine on RewriteCond %{HTTP:KERSSL} !on RewriteRule ^(.*)$ https://example.com/$1 [L,R=301] RewriteCond %{HTTP:KERSSL} on RewriteCond %{HTTP_HOST} !^example.com [NC] RewriteRule ^(.*)$ https://example.com/$1 [L,R=301] |
17
Totato5749 OP @lslqtz
@hqfzone 真的谢谢你们,在 @hqfzone 的基础上改了下可以了,大概是因为 apache 不能用 443 来判断? RewriteEngine on RewriteCond %{HTTP:KERSSL} !on [OR] RewriteCond %{HTTP_HOST} !^example.com$ [NC] RewriteRule "^/?(.*)" "https://example.com/$1" [L,R=301] |