Remove index.php from the URL in CodeIgnitor
In CodeIgnitor MVC, by default index.php will be included in the URL like
application_name.com/news/article/my_article
Good thing about web application that uses CodeIgnitor framework is that we can remove that index.php from the URL of application by simple configuration on CodeIgnitor.
The three major configuration steps are as follows
STEP 1: CREATE .htaccess file
Create a .htaccess file in root directory of your application or you can simply copy .htaccess file from the folder inside the application folder or system folder in CodeIgnitor in your root directory of your application.
That is folder inside your_application_name/
Now copy the following code and paste the following in .htaccess file in root of your application
RewriteEngine On
RewriteBase /CodeIgniter/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Now replace above bold CodeIgniter with your application name
STEP 2: change config.php file
Open the config.php file found inside the application_name/application/config/
Change $config[‘index_page’] to blank in config.php in application folder as below
$config['index_page'] = ' ';
STEP 3:
Enable “rewrite_module” of apache server.
Congrats!!! you have configure your CodeIgnitor MVC Framework successfully.
Now you can access your site without index.php in url.
We keep on updating such tutorials.
For more such tutorials like our Facebook page.
good idea mr.tapan
ReplyDeletethank you