Customize url in ci-3

Customize url in ci-3

url structure:

base_url/controllername/functionname

Remove controllername from url:

/application/config/routes.php

$route['default_controller'] = 'welcome';
$route['^(?!other|controller).*'] = 'welcome/$0';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

Remove index.php from url:

create .htaccess file at root directory

Options +FollowSymlinks
RewriteEngine on

RewriteCond $1 !^(index\.php)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?/$1 [L]

 

 

 

Leave a Reply