将uri_protocol更改为PATH_INFO会破坏我的CodeIgniter应用程序?

时间:2010-12-14 05:30:01

标签: codeigniter apache2 pathinfo

我正在为CodeIgniter设置Haughin的Twitter OAuth库,一个要求是将config.php中的uri_protocol更改为PATH_INFO,这似乎是以所有请求加载家庭控制器的方式打破我的应用程序(例如,导航到http://dev.myapp.com/login通常会将我带到Login控制器,但它只显示默认控制器。)

任何可能导致此问题的想法,或者可能是混乱的Apache2配置?

1 个答案:

答案 0 :(得分:4)

与URL重写有关。检查.htaccess文件以查看是否有正确的重写规则。使用PATH_INFO时,这对我有用。

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

上述内容适用于您,无需任何修改。如果你在一个文件夹中托管,比如 http://myserver.com/my_app/ ,那么将 /index.php 更改为 / my_app / index。 php 在这两个地方。