强制 https://www.使用 mod_rewrite 在 htaccess 中使用 Codeigniter [英] Force https://www. for Codeigniter in htaccess with mod_rewrite
本文介绍了强制 https://www.使用 mod_rewrite 在 htaccess 中使用 Codeigniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Codeigniter 并遵循这些说明强制 ssl 但所有请求都被重定向到
I'm using Codeigniter and following these instructions to force ssl but all requests are being redirected to
http://staging.example.com/index.php/https:/staging.example.com
我的 .htaccess
是:
### Canonicalize codeigniter URLs
# Enforce SSL https://www.
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
###
# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
推荐答案
我认为,而不是
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
你应该有类似的东西
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
确实有重写规则匹配.您的链接目前由第三条规则生成.
do have the rewrite rule match. Your link is currently produced by the third rule.
这篇关于强制 https://www.使用 mod_rewrite 在 htaccess 中使用 Codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文