问题htacess重定向从http到https
问题描述:
我去了整个网站只能使用https进行联系。问题htacess重定向从http到https
在.htaccess
到我写了下面的规则
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.my-website.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.my-website.com/$1 [R,L]
但它会导致“此网页有重定向循环” 任何人都可以指导我修复此。
答
通常用一个单一的网站,你可以使用:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule^https://www.my-website.com%{REQUEST_URI} [R=301,L]
使用[不建议您使用情况的mod_rewrite(https://wiki.apache.org/httpd/RedirectSSL)。但是,你真的不得不尝试[这个例子](https://wiki.apache.org/httpd/RewriteHTTPToHTTPS)。 – 2014-11-24 15:23:10