【问题标题】:Cakephp Security component Forcessl conflicts with RewriteRuleCakephp 安全组件 Forcessl 与 RewriteRule 冲突
【发布时间】:2014-02-04 06:02:09
【问题描述】:

我正在使用安全组件 forcesl 在整个网站中强制使用 https。

对于https://www.domain.com/pages/detail/terms,在.htaccess文件中,我重写规则如下

RewriteRule ^(terms)$ pages/detail/$1/ [L]

所以它应该重定向到 https://www.domain.com/terms。

当使用 https://domain.com/terms 访问术语页面时,它会重定向到 https://www.domain.com/terms。

当使用http://domain.com/terms 访问条款页面时,它会重定向到 https://www.domain.com/pages/detail/terms。

这是因为控制器中的forcessl:

$this->redirect('https://' . $_SERVER['SERVER_NAME'] . $this->here); 
$this->here

指向原始页面(页面/详细信息/条款)。如何解决这个问题。

【问题讨论】:

    标签: php .htaccess cakephp


    【解决方案1】:

    您是否尝试过使用 Cake PHP 的路由功能?在config/routes.php 中添加以下内容:

    Router::connect(
        '/terms',
        array(
            'controller' => 'pages',
            'action' => 'detail',
            'terms'
        )
    );
    

    【讨论】:

    • 不,我现在试过了,没有运气。 Forcessl 函数将当前请求重定向到 https,url 转向 domain.com/pages/detail/terms。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多