简体   繁体   中英

Removing the index.php file of codeigniter

http://codeigniter.com/user_guide/general/urls.html
I am using a MAMP setup I access my codeigniter welcome message as follows

http://localhost:8888/CodeIgniter_2.0.2/index.php/welcome

the tutorial says

use a .htaccess file as

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

to get same message with

http://localhost:8888/CodeIgniter_2.0.2/welcome

but I get a 404 not found error instead

First things first, you need to check your httpd.conf
Look for this line.. (the location may not be the same)

LoadModule rewrite_module libexec/apache2/mod_rewrite.so

Make sure it's uncommented. Then save your changes and restart apache server.

Also, make sure that the .htaccess file is in the same directory as your index.php .
It's usually the base directory of your CodeIgniter application.

EDIT:

Also forgot to mention that you need virtual hosts for this work seamlessly.
Argh, it seems your question is a repost. Here's another question but this is on a MAC OS X platform, with some detail on setting up your virtual hosts.
Remove "index.php" from URL - Codeigniter

the last line should be

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

and not

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

Try to add RewriteBase on your htacces file.

RewriteEngine On
RewriteBase "/CodeIgniter_2.0.2/"
...your rules here...

the instructions you followed assume you are installing code igniter in the docroot, and not a subdirectory. move all your files in /CodeIgniter_2.0.2 down a directory.

mv CodeIgniter_2.0.2/* .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM