将http重定向到https,但首页

时间:2016-12-13 12:36:07

标签: php regex .htaccess

我一直在尝试将所有网址http重定向到https,但首页除外。我已针对特定url,即sign-in做了,但我需要在主页上进行此操作。请看下面我做了什么:

RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} /sign-in [NC] // don't understand what should be for hompage instead of sign-in
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !/sign-in [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

如果有人能帮助我,那将是最大的帮助。

1 个答案:

答案 0 :(得分:0)

将这两条规则放在所有其他规则之上:

-bash: alias: `': invalid alias name