htaccess重定向到https:// www url

时间:2016-05-26 20:20:24

标签: apache .htaccess mod-rewrite https url-redirection

我必须使用htaccess在https://www.example.com上重定向我的网站。

我已经使用了很多解决方案但是当我删除" s"从https我的网站运行http和&当我只运行www.example.com然后它将在http上运行它只适用于" example.com"。

我使用的解决方案如下所述

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]  
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

是否有人有神奇的解决方案。

1 个答案:

答案 0 :(得分:0)

使用:

# http(s)://domain  ->  https://www.domain
RewriteCond %{HTTP_HOST} !^www\. [OR,NC]
RewriteCond %{HTTPS} off 
RewriteRule ^ https://www.domain.com%{REQUEST_URI} [NE,R=301,L]
相关问题