.htaccess - 存在生根系统时从 HTTP 到 HTTPS

标签 .htaccess ssl https

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

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

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

我试着添加这个,但是路由坏了:

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

谁能帮帮我?

谢谢!

最佳答案

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

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

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

关于.htaccess - 存在生根系统时从 HTTP 到 HTTPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33503613/

相关文章:

apache - 如何从 Apache .htaccess 创建虚拟主机?

.htaccess - 在 htaccess 中从 URL 中删除不需要的字符

html - 我应该将网站的所有网址重定向到 https 吗?

ssl - Heroku 网络套接字连接

android - Android 4.4 中的自适应播放

java - Android 使用证书建立 HTTPSConnection

Php:使用 web.config 重写 URL

java - keytool导入证书和java系统属性

ssl - 账户密码传输和 PCI DSS 合规性

php - https 登录表单