CodeIgniter Remove index.php in URL - Mostlikers

14 May, 2015

CodeIgniter Remove index.php in URL

In this post i want to discuses about how to remove index.php from URL using .htaccess file in CodeIgniter. By default CodeIgniter developed with index.php extension from the url. For using httaccess you can hide from the url. 

CodeIgniter Remove index.php in URL


Htaccess

htaccess is short for Hypertext Access. It is configuration file for use on web servers running the Apache Web Server software.

CodeIgniter htaccess

1.Open your config file change below code. application/config/config.php

$config['index_page'] = "index.php" 
                      to 
$config['index_page'] = "" 

2.Create a new file name called as .htaccess save to project folder location

path : your_folder/.htaccess

CodeIgniter Remove index.php in URL

3.Copy the the below code and paste below code .htaccess file. Now you can access url without index.php 

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

Example :

Thank you for visiting. if have any queries write comments below.


"To be yourself in a world that is constantly trying to make you something else is the greatest accomplishment."
                                             
                                         - Ralph Waldo Emerson








Related Topics

No comments:

Post a Comment