I would like to explain about removing index.php from codeigniter based application urls with .htaccess.To hide “index.php” from the URL, add an .htaccess file to your web root, with following text:
NOTE: If you are website located in sub directory , instead of '
After add
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.
RewriteEngine On
RewriteBase /
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
NOTE: If you are website located in sub directory , instead of '
RewriteBase /
‘ add ‘RewriteBase /sub directory name
‘.For example if you webiste located in htdocs/ciapp/
then the rule should be RewriteBase /ciapp
.After add
.htaccess
file go to applications/config/
open config.php
, in the config array, remove index_page
valueIn some cases default settings of uri_protocol doesn’t work properly.To fix this problem just change below code in
$config['index_page'] = “index.php”;
//to
$config['index_page'] = “”;
config.php
located at application/config/
directory
$config['uri_protocol'] = “AUTO”
//with
$config['uri_protocol'] = “REQUEST_URI”;
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.
Comments