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 apa
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 hosts
Include /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 localhost
127.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 -S To 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.
copy the .htaccess on your main codeigniter folder, mine was localhost/codeigniter/ and then change the {RewriteBase / to RewriteBase /codeigniter/}
To remove index.php from URL just add
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* 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'] = '';
in /etc/apache2/users/.conf
try adding ..
<Directory "/Users/<your user name>/Sites/">
Options Indexes MultiViews FollowSymlinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
and restart Apache to check results ..
Since your CI installation is not into your document root you should add RewriteBase /code/
to make it works.
This is my .htacces I use for a CI installation (this is little bit more elaborated than the one provided with the official documentation):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /code/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
Also make sure your httpd can handle .htaccess file. Check into httpd.conf if exists a line with AllowOverride all
inside a <Directory></Directory>
element
Hope this help
From the words of the CodeIgniter documentation
By default, the index.php file will be included in your URLs:
example.com/index.php/news/article/my_article You can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the "negative" method in which everything is redirected except the specified items:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
In the above example, any HTTP request other than those for index.php, images, and robots.txt is treated as a request for your index.php file.
you can find it here: http://codeigniter.com/user_guide/general/urls.html