CodeIgniter always routes via index.php?

Beginner CodeIgniter. My site's main url is http: // localhost / routing / '.

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

      

I'm just trying to redirect the url http: // localhost / routing / admin 'to the admin controller using the following rules, but it doesn't work, I have to use' http: //localhost/routing/index.php/admin ' instead ...

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

      

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

+3


source to share


3 answers


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



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

+4


source


Make changes to .htaccess file and config.php

applications / config.php

$config['index_page'] = '';

      



.htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

      

+5


source


In yours, .htaccess

write this. Also find more information: Coding Guide

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

      

0


source







All Articles