Getting CodeIgniter URLs properly rewritten is a bit tricky when using FastCGI, including the mod_fastcgi_handler. Typically, we want to remove the index.php from all urls. To do this, create an .htaccess file in the same directory with index.php and paste into it:

Options -Indexes +FollowSymLinks

RewriteEngine On
RewriteBase /

# exclude any paths that are not codeigniter-app related
RewriteCond %{REQUEST_URI} !^/server-status
RewriteCond %{REQUEST_URI} !^/server-info
RewriteCond %{REQUEST_URI} !^/docs

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

<IfModule mod_php5.c> 
    RewriteRule ^(.*)$ index.php/$1 [L]    
</IfModule>    

# the following is for rewritting under FastCGI
<IfModule !mod_php5.c>    
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

Acknowledgements

Full credit for the right mod_rewrite rule goes to Phil Sturgeon who has posted it here.

Share this: