从http重定向到https不起作用

时间:2017-11-19 11:30:29

标签: apache .htaccess redirect mod-rewrite https

RewriteEngine On RewriteCond%{SERVER_PORT}!443 RewriteRule ^(/(。*))?$ https://% {HTTP_HOST} / $ 1 [R = 301,L]

这是我在.htaccess文件中使用的命令,当我键入arion-software.co.uk时,它没有正确重定向。 任何想法?

2 个答案:

答案 0 :(得分:0)

这应该有用,对我有用。

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]

这是我从以下地方获得的:redirect http to https

编辑:该链接为您的域提供了示例,无论是否有" www。"子域。

答案 1 :(得分:0)

你去,http到https重写:

## Redirecting HTTP to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]