promotion

Saturday, March 21, 2015

How to remove index.php from codeigniter url?

Codeigniter defaultly add index.php in the url because that file is responsible for processing all requests to the system. But, we can easily remove index.php by using URL Rewriting.
Here are the simple steps:
1. Update general configuration:
Open config.php from system/application/config directory and replace
$config["index_page"] = "index.php";

with

$config["index_page"] = "";
2.Create an .htaccess file
Create a new file named .htaccess in the root directory and write below code in that file:
RewriteEngine on
RewriteCond $1 !^(index\.php|css|images|js|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]

No comments:

Post a Comment