Search code examples
codeigniterapache2pathinfo

Changing uri_protocol to PATH_INFO breaks my CodeIgniter app?


I'm setting up Haughin's Twitter OAuth Library for CodeIgniter, and one requirement is to change the uri_protocol in config.php to PATH_INFO, which seems to be breaking my app in the way that all requests load the home controller (ex. Navigating to http://dev.myapp.com/login would normally take my to the Login controller, but it's just showing the default controller.)

Any ideas what would be causing this, or maybe an Apache2 configuration that's messed up?


Solution

  • Its to do with URL rewrites. Check your .htaccess files to see if you have the correct rewrite rules. Here is something that works for me when using 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>
    

    The above should work for you without any modification. If you're hosting in a folder lets say like http://myserver.com/my_app/ then change /index.php to /my_app/index.php in both places.