darkddfgg 发表于 2018-6-7 00:28:58

关于https、index.php的.htaccess写法问题

最近做一个CI项目,需要用到https,但是根据隐藏index.php入口文件的写法,2、3行是自带的
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(application|modules|plugins|system|themes) index.php/$1
刚使用CI不久,网上也没查询到相关的内容,都是其他框架或者单纯的Apache的设置,搬过来倒是可以支持重定向到https,但是入口文件index.php又出现在了URL上:域名/index.php/Admin/index/index,劳烦大神帮解答一下

Hex 发表于 2018-6-7 00:46:59

你的问题是什么?把 http:// 转到 https:// 上?

darkddfgg 发表于 2018-6-7 21:12:08

Hex 发表于 2018-6-7 00:46
你的问题是什么?把 http:// 转到 https:// 上?

额,我已经改好了https,现在的问题是我想访问站点的时候自动用的是https而不是http,网上都是说改根目录下的.htaccess文件, 但是之前为了隐藏入口文件就添加了一些内容在里面,不知道怎么处理:L

Hex 发表于 2018-6-8 00:04:49

darkddfgg 发表于 2018-6-7 21:12
额,我已经改好了https,现在的问题是我想访问站点的时候自动用的是https而不是http,网上都是说改根目录 ...
那就是访问 http:// 的时候 做一个301跳转到 https:// 上。做一个 rewrite 跳转即可,不影响 CI 的 rewrite 规则啊。

我简单搜了一下,因为很早就不用 apache 了,所以不知道行不行,nginx 做这件事更简单。


RewriteEngine On
RewriteCond %{HTTPS}!=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1
页: [1]
查看完整版本: 关于https、index.php的.htaccess写法问题