力的https:// WWW。为codeigniter htaccess的与mod_rewrite的 [英] Force https://www. for Codeigniter in htaccess with mod_rewrite

查看:248
本文介绍了力的https:// WWW。为codeigniter htaccess的与mod_rewrite的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用codeigniter并按照<一href="http://stackoverflow.com/questions/4398951/force-ssl-https-using-htaccess-and-mod-rewrite">these说明强制SSL,但所有的请求都被重定向到

  http://staging.example.com/index.php/https:/staging.example.com
 

我的的.htaccess 是:

  ###。规范化codeigniter网址

#强制SSL的https:// WWW。
的RewriteCond%{} HTTPS!=上
重写规则^的https://%{HTTP_HOST}%{REQUEST_URI} [L,R = 301]

###
#删除用户访问系统文件夹中。
#此外,这将允许您创建一个System.php控制器,
#previously这将是不可能。
#'系统'可以,如果你已重命名系统文件夹进行更换。
的RewriteCond%{REQUEST_URI} ^系统。*
重写规则^(。*)$ /index.php/$1 [L]

#检查是否该用户正在试图访问一个有效的文件,
#如图像或CSS文档,如果这是不正确的发送的
#请求的index.php
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php / $ 1 [L]
 

解决方案

我想,而不是

 重写规则^ https://开头%{HTTP_HOST}%{REQUEST_URI} [L,R = 301]
 

您应该有一些像

 重写规则^ * $ HTTPS://%{HTTP_HOST}%{REQUEST_URI} [L,R = 301]
 

确实有重写规则匹配。你的链路是由第三个规则目前生产

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

My .htaccess is:

### 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]

解决方案

I think, instead of

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

you should have something like

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。为codeigniter htaccess的与mod_rewrite的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆