Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove index.php from url in CodeIgniter 3

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

This is my baseurl

http://cableandmedia.com/demo/
like image 943
Yadhu Babu Avatar asked Jul 20 '16 09:07

Yadhu Babu


People also ask

How can I change my URL in CodeIgniter 3?

Show activity on this post. change your controller function name as you like. public function addcar($value='') { # code... } public function deletecar($value='') { # code... }

Where is route in CodeIgniter?

Routing rules are defined in your application/config/routes. php file. In it you'll see an array called $route that permits you to specify your own routing criteria. Routes can either be specified using wildcards or Regular Expressions.


1 Answers

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;
like image 129
Deepak Dholiyan Avatar answered Oct 07 '22 13:10

Deepak Dholiyan