Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter routing always through index.php?

CodeIgniter beginner here. The base URL of my website is 'http://localhost/routing/'.

// config.php
$config['base_url'] = 'http://localhost/routing/';

I'm simply trying to route the url 'http://localhost/routing/admin' to the admin controller using the following rules but it doesn't work. Instead I have to use 'http://localhost/routing/index.php/admin'.

$route['default_controller'] = 'seasons';
$route['admin'] = 'admin';
$route['404_override'] = '';

Question: is there a way to remove 'index.php' from the url?

like image 336
Frank Ross Avatar asked Sep 25 '26 23:09

Frank Ross


2 Answers

Make changes in .htaccess file and config.php

application/config.php

$config['index_page'] = '';

.htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
like image 70
Slipstream Avatar answered Sep 28 '26 22:09

Slipstream


is there a way to remove 'index.php' from the url?

Yes, as well as being a very popular question on SO, it is covered in the CodeIgniter documentation (which is very good and I highly recommend reading).

like image 43
Colin Brock Avatar answered Sep 28 '26 21:09

Colin Brock



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!