I have looked within the documentation of Codeigniter of getting rid of the index.php in the URL when being able to access different sights, the code shows how you can take it off with apache:

RewriteEngine on

RewriteCond $1 !^(index.phpimagesrobots.txt)

RewriteRule ^(.*)$ /index.php/$1 [L]

However, after i visit http://localhost/code/home, I recieve this:

The asked for URL /code/home wasn't available on this server.

But being able to access http://localhost/code/index.php/home works all right, why it is not employed by me?

I am on the Mac OS X Snow Leopard while using Sites directory: /Customers/~myusername~/Sites/code, and I am not using any software, i.e. MAMP, XAMPP.


For that sudo /usr/sbin/apachectl -k restart -S command, I recieve this:

VirtualHost configuration:

wildcard NameVirtualHosts and _default_ servers:

*:80                   is really 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

You have to make "http://localhost/code" your internet root as 'code.local' (during my example). Presuming that the setup on Mac OS X Snow Leopard is equivalent to mine.

You need to add the next lines to "/etc/apache2/extra/httpd-vhosts.conf"

<VirtualHost *:80>

    DocumentRoot "/Customers/~myusername~/Sites/code"

    ServerName "code.local"

    ErrorLog "/private/var/log/apache2/code-error_log"

    CustomLog "/private/var/log/apache2/code-access_log" common


Also make certain that it's uncommented in "/etc/apache2/httpd.conf"

# Virtual hosts

Include /private/etc/apache2/extra/httpd-vhosts.conf

Then you definitely add code.close to your "/etc/hosts" that ought to seem like this


# Host Database


# localhost can be used to configure the loopback interface

# once the product is startup.  Don't change this entry.


127...1       localhost

127...1       code.local

Then restart your apache "/usr/sbin/apachectl -k restart".

You will need to sudo if you're not an excellent user. Hope this can help.

EDIT: To see if your virtual host works. Run this sudo /usr/sbin/apachectl -k restart -S To ascertain if code.local continues to be added among your virtual hosts.

Then try being able to access code.local/index.php/welcome and code.local/welcome to see if it really works.

Try that one

DirectoryIndex index.php

RewriteEngine on

RewriteCond $1 !^(index.php(.*).swfforumsimagescssdownloadsjsrobots.txtfavicon.ico)

RewriteCond % !-f

RewriteCond % !-d

RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]

I attempted 3 before I acquired someone to work

You need to change

RewriteRule ^(.*)$ /index.php/$1 [L]


RewriteRule ^(.*)$ /code/index.php/$1 [L]

You should also customize the $config['index_page'] variable such as this:

$config['index_page'] = ''

Please make reference to my publish at http://world wide web.boxoft.internet/2011/07/getting rid of-index-php-from-codeigniter-2--2-url/ if you want.