Remove "index.php" from URL - Codeigniter Remove "index.php" from URL - Codeigniter codeigniter codeigniter

Remove "index.php" from URL - Codeigniter


You need to make "http://localhost/code" your web root as 'code.local' (in my example).Assuming that your setup on Mac OS X Snow Leopard is the same as mine.

You should add the following lines to "/etc/apache2/extra/httpd-vhosts.conf"

<VirtualHost *:80>    DocumentRoot "/Users/~myusername~/Sites/code"    ServerName "code.local"    ErrorLog "/private/var/log/apache2/code-error_log"    CustomLog "/private/var/log/apache2/code-access_log" common</VirtualHost>

Also make sure that it is uncommented in "/etc/apache2/httpd.conf"

# Virtual hostsInclude /private/etc/apache2/extra/httpd-vhosts.conf

Then you add code.local to your "/etc/hosts" which should look like this

### Host Database## localhost is used to configure the loopback interface# when the system is booting.  Do not change this entry.##127.0.0.1       localhost127.0.0.1       code.local

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

You might need to sudo if you are not a super user.Hope this helps.

EDIT:To check if your virtual host works. Run this sudo /usr/sbin/apachectl -k restart -STo see if code.local has been added as one of your virtual hosts.

Then try accessing code.local/index.php/welcome and code.local/welcome to check if it works.


Try this one

DirectoryIndex index.phpRewriteEngine onRewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ ./index.php?$1 [L,QSA] 

I tried 3 before I got one to work


To remove index.php from URL just add

RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule .* index.php/$0 [PT,L]

in the .htaccess file and move the .htaccess file near to index.php location

/var/www/CodeIgniter/index.php/var/www/CodeIgniter/.htaccess

in config.php in config folder set

$config['index_page'] = '';