• 1
name Punditsdkoslkdosdkoskdo

Remove “index.php” from URL - Codeigniter

I've looked in the documentation of Codeigniter of removing the index.php from the URL when accessing different views, the code shows how to remove it with apache:

RewriteEngine on
RewriteCond $1 !^(index.php|images|robots.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

However, when I go to http://localhost/code/home, I get this:

The requested URL /code/home was not found on this server.

But accessing http://localhost/code/index.php/home works just fine, how come it isn't working for me?

I'm on a Mac OS X Snow Leopard using the Sites directory: /Users/~myusername~/Sites/code, and I'm not using any software, i.e. MAMP, XAMPP.


For the sudo /usr/sbin/apachectl -k restart -S command, I get this:

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server code.local (/private/etc/apache2/httpd.conf:146)
         port 80 namevhost code.local (/private/etc/apache2/httpd.conf:146)
Syntax OK