有生根系统时,HTTP到HTTPS

时间:2015-11-03 16:00:06

标签: .htaccess ssl https

我想将我网站的每个网址从http://重定向到https://

我的问题是我在我的.htaccess中有一个路由系统:

RewriteRule ([^.]+)\.html$ index.php?/$1 [QSA,L]

我尝试添加此功能,但路线已损坏:

RewriteCond %{HTTPS} off    
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

任何人都可以帮助我吗?

谢谢!

2 个答案:

答案 0 :(得分:0)

在旧的RewriteRule之前将HTTP添加到HTTPS:

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

RewriteRule ([^.]+)\.html$ index.php?/$1 [QSA,L]

答案 1 :(得分:0)

我找到了好的陈述:

RewriteCond %{SERVER_PORT} !443
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]