To set up URL friendly in Codeigniter follow the following steps described below.
Note: These steps are not necessarily sequential.
- In the files . /sua_pasta_projeto/application/config/config.php change the following value of the $config vector index_page:
Of:
$config['index_page'] = 'index.php';
To:
$config['index_page'] = '';
- If not, create the . htaccess file at the root of your project (sua_pasta_project/.htaccess) with the following contents:
Contents:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
- In the same config.php file change the value of the base_url key of the $config array;
To:
$config['base_url'] = 'http://sua_url_projeto/';
In your case you’ll probably stay:
$config['base_url'] = 'http://localhost:8087/CodeIgniter/';
Remembering that you will be able to access your project so much:
http://localhost:8087/sua_pasta_projeto/index.php/controller/method_action
Like:
http://localhost:8087/sua_pasta_projeto/controller/method_action
Remember also that the route.php file serves to configure custom routes, not to configure the default Codeigniter friendly URL.
In the config.php file you have already taken the index php. of
$config['index_page'] = '';
. also checks the file .htaccess– Italo Izaac