Yadhu Babu Yadhu Babu - 1 year ago 122
PHP Question

Remove index.php from url in codeigniter3

Hi I am doing a project in codeigniter3. I need to remove index.php from url. For that help me to get .htaccess file for codeigniter3 and also where to place this file.


This is my baseurl

Answer Source

Update your htaccess file with the below code

RewriteEngine On
RewriteBase /demo
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

and in config file, please change base url with below code:-

$root  = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url']    = $root;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download