【问题标题】:Exclude a codeigniter URL pattern from http to https redirect从 http 到 https 重定向排除 codeigniter URL 模式
【发布时间】:2015-05-29 23:37:01
【问题描述】:

我有一个 codeigniter 项目。这是它的 .htaccess 文件:

RewriteEngine on

#HTTPS redirection    
RewriteCond %{HTTPS} =off
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

#CodeIgniter Rules
RewriteCond $1 !^(index\.php|css|img|js|fonts|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

基本上,我将所有非 https 流量重定向到 https。我的问题是我要从这个重定向中排除一个 codeigniter 控制器及其所有 URL。一些控制器的 URL 结构是:

http://example.com/external/?url=blablabla
http://example.com/external/
http://example.com/external/out/543260
http://example.com/external?goto=blablablabla

所以这些是 codeigniter URL。它们不是文件或目录。我已经尝试了所有可能的 RewriteCond 来排除这些 URL,但它不起作用。

如何从 HTTP -> HTTPS 重定向中排除这些 codeigniter 路由 url

【问题讨论】:

  • 在第一条规则之前尝试将RewriteCond %{REQUEST_URI} !^/external/?url=blablabla$ 作为第二个条件。
  • @Tpojka 没用。我认为问题在于 /external/ 是 codeigniter 重新路由的路径,而不是服务器上的真实目录或文件。

标签: .htaccess codeigniter url-rewriting


【解决方案1】:

我想我知道问题出在哪里。 /external/ 是一个 codeigniter 模块,因此,它被重写为 /index.php?/external 。 index.php 被重写为 HTTPS,这就是它被重写为 HTTPS 的原因。我所要做的就是从 HTTPS 重写规则中排除 index.php?/external。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-07
    • 2014-03-17
    • 2018-04-17
    • 2016-06-06
    • 2016-04-29
    • 2017-06-13
    • 1970-01-01
    • 2021-09-23
    相关资源
    最近更新 更多