Google

Sunday, May 3, 2009

CodeIgniter - Removing index.php by Changing .htaccess and httpd.conf

I've done this many, many times. But whenever I setup a new site on a new developer machine, I will have to do research over and over again. I decided to write down the details, actually only a few steps.
  1. Remove the index.php in the CI config file
    $config['index_page'] = "";

  2. Add .htacess file in the root of your application
    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]

  3. Uncomment the mod_rewrite in httpd.conf
    LoadModule rewrite_module modules/mod_rewrite.so

  4. Change None to All
    <Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from all
    </Directory>

  5. As well as the web root folder (this is needed)
    <Directory "C:Apache/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>
And done!

No comments: