.htaccess https重定向失败

时间:2017-04-21 09:09:33

标签: .htaccess ssl

我在我正在测试的域上设置了SSL证书,您可以在此处看到SSL工作:https://naughtyrobot.co.uk/ - 我还在此处验证了我的域名是否有有效的SSL证书:https://www.ssllabs.com/ssltest/analyze.html?d=naughtyrobot.co.uk

我在根目录中创建了一个.htaccess文件,它看起来像这样:

RewriteCond %{ENV:SSL} ^$ [OR]
RewriteCond %{HTTP_HOST} !^www\.naughtyrobot\.co.uk
RewriteRule (.*) https://naughtyrobot.co.uk/$1 [R=301,L]

我通过查看:etc/apache2/sites-enabled/000-default-le-ssl.conf

检查以确保根目录正确无误

但是,如果您访问naughtyrobot.co.uk,它似乎只是路由到标准http://

1 个答案:

答案 0 :(得分:1)

将您的规则更改为:

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule ^ https://naughtyrobot.co.uk%{REQUEST_URI} [R=301,L,NE]