【问题标题】:Codeigniter, OpenID and .htaccessCodeigniter、OpenID 和 .htaccess
【发布时间】:2011-03-18 09:54:37
【问题描述】:

我正在尝试使用Codeigniter OpenID library,并且在没有.htaccessCI 的默认配置下一切正常。

当我通过更改 config.php.htaccess 删除 index.php 时,当我尝试验证我的 openid (http://ci.dlsb.eu/test/) 时,我得到 404 Page Not Found

谁能告诉我哪里错了?

config.php

$config['index_page'] = "";

.htaccess

RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

【问题讨论】:

    标签: php .htaccess codeigniter openid


    【解决方案1】:

    您的 RewriteRule 尝试在每个目录的上下文中创建 PATH_INFO,据我所知,这在请求处理阶段发生得太晚而无法正常工作。

    最好的解决方案是干脆不这样做,因为 CodeIgniter 不需要它来运行:

    RewriteEngine on
    RewriteBase /
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ /index.php
    

    只要您将$config['uri_protocol'] 设置为AUTO,CodeIgniter 应该能够自行确定正确的请求是什么。如果不是,您应该将其设置为AUTOREQUEST_URI

    【讨论】:

    • 好的,我修复了我的 .htaccess,$config['uri_protocol'] 设置为 REQUEST_URI,但我仍然收到相同的错误...
    • 是的,我可能有点跑题了。这是因为表单提交到的 URL 没有尾部斜杠,所以 CodeIgniter 的路由以某种方式失败。我会检查一下为什么会这样,然后告诉你如何解决它。
    • 当我设置 $config['url_suffix'] = "/";一切正常。谢谢蒂姆!
    猜你喜欢
    • 1970-01-01
    • 2020-12-08
    • 2012-11-10
    • 1970-01-01
    • 1970-01-01
    • 2014-09-25
    • 2012-02-03
    • 2011-05-29
    • 1970-01-01
    相关资源
    最近更新 更多