I have a problem. I need to remove index.php from URL in CodeIgniter framework. Anybody can help me?
Asked
Active
Viewed 683 times
0
-
But this is not a question... See more here http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/ – idmean May 25 '14 at 14:44
3 Answers
2
for lighttpd:
enable mod_rewrite module and set this in you lighttpd.conf
server.document-root = "/var/www/ci/",
url.rewrite-once = (
"/(.*)\.(.*)" => "$0",
"/(css|files|img|js|stats|user_guide)/" => "$0",
"^/([^.]+)$" => "/index.php/$1"
)

Michael D.
- 1,795
- 2
- 18
- 25
0
To avoid "index.php" from codeigniter url, follow the steps below.
1.Open config.php from system/application/config directory and replace
$config['index_page'] = “index.php”
by
$config['index_page'] = “”;
2.Create a “.htaccess” file in the root of CodeIgniter directory (where the system directory resides), open the file using your favorite text editor, write down the following script and save it:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
3.In some case the default setting for uri_protocol does not work properly. To solve this problem just replace
$config['uri_protocol'] = “AUTO”
by
$config['uri_protocol'] = “REQUEST_URI”
from system/application/config/config.php

Joe
- 618
- 1
- 9
- 18
0
You just need to create .htaccess file in project folder and write:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
#And You don't need to define in base_url in config file:
$config['base_url'] = '';// blank it.
I hope You Understand..

SysDragon
- 9,692
- 15
- 60
- 89

Jay Kareliya
- 760
- 7
- 21