php - 使用 codeigniter htaccess 在整个站点上强制使用 ssl

标签 php apache .htaccess ssl

我有一个 codeigniter 站点,我希望它始终强制使用 ssl。我正在使用 htaccess 文件删除丑陋的 index.php

这是我现在拥有的 htacces 文件的内容...

 RewriteEngine on
 RewriteCond $1 !^(index\.php|static|robots\.txt)
 RewriteRule ^(.*)$ /index.php/$1 [L]

我必须做什么才能让它始终使用 ssl?

谢谢!

最佳答案

试试这个:

RewriteEngine On
#RewriteCond %{HTTPS} !=on
RewriteCond %{HTTPS} off
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond $1 !^(index\.php|static|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

关于php - 使用 codeigniter htaccess 在整个站点上强制使用 ssl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15589057/

相关文章:

apache - .htaccess文件夹到虚拟文件夹重写

php - 从 sql 获取前 12 个月

php - PHP 中的 Mysql 插入语句

apache - 将模块加载到 Apache

Apache .htaccess 与 httpd - 这真的很重要吗?

php - 需要路由到不同的 php 文件并使用 .htaccess 调用单独的函数

php - 网站没有正确重定向

php - 通过电子邮件或手机在 Laravel 中重置密码

php - 在 php 中调用大量 mysql_query 后出现 500 错误

apache - 简单重定向apache无限循环