[英]Unable to Force SSL/https using .htaccess
我在主机上使用开放学校php,并且试图在我的网站上强制使用ssl,但是当我添加此代码时
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
但随后我无法访问我的网站,因为浏览器显示太多循环或重定向
页面未正确重定向
Firefox已检测到服务器正在以永远无法完成的方式重定向对该地址的请求。
这是原始的htacess文件,请帮助
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On
#Admin
Rewriterule ^admin$ index.php?r=Cms/admin/home
#Install
Rewriterule ^install$ install.php?r=Install/default
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(js|ico|gif|jpg|png|css)$
# otherwise forward it to index.php
RewriteRule . index.php
而不是使用%{SERVER_PORT}
行,请尝试以下操作:
RewriteCond %{HTTPS} !=on
这是一个完整的.htaccess
文件,我用来强制任何网站使用SSL:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.