2
votes

I've created a .htaccess file in my document root at /var/www/html/ to rewrite URL of Codeigniter to remove "index.php" from URL of all pages.

e.g. Change URL from

http://myhost/index.php/controller/function

to

http://myhost/controller/function`

Here is the code of my `/var/www/html/.htaccess

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

I've got many suggestions from googling to enable mod-rewrite module, but I can see in my httpd.conf its already enabled.

LoadModule rewrite_module modules/mod_rewrite.so

This is perfectly working on my local system running on Debian 7 (Apache/2.4.4).

Any help would be appreciated. :)

2

2 Answers

14
votes

You need to also specify the locations that can use it. For example, in /etc/httpd/conf/httpd.conf you should see something like:

<Directory "/var/www/html">

      ...lots of text...

</Directory>

Make sure is has:

<Directory "/var/www/html">

    AllowOverride All

</Directory>
0
votes

It's possible that your centos server isn't setup to handle PATH INFO. Try replacing the index.php/$1 in your rule's target to index.php?/$1.

Then you need to modify your CI config to enable query strings: http://ellislab.com/codeigniter/user-guide/general/urls.html

In you application/config.php file set $config['enable_query_strings'] to TRUE.