3
votes

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?

3

3 Answers

7
votes

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]
4
votes

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).

0
votes

In your .htaccess write this. Also look for additional information : Codeigniter Guide

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt) # exceptions
RewriteRule ^(.*)$ /index.php/$1 [L]