Yousuf Memon Yousuf Memon - 1 year ago 67
PHP Question

How to remove controller name from url making it clean in codeigniter

I have the following url..


I want to remove
controller from url resulting in..


How can I do this in CodeIgniter ?

Note: If you'll ask what I've tried than I've just done searching over Google as I don't know how to use mod_rewrite.


I have this in my routes.php

$route['default_controller'] = "site_controller/home";
$route['ci/home'] = 'ci/site_controller/home';
$route['404_override'] = '';

but still not working!


RewriteEngine On
RewriteBase /ci/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

ErrorDocument 404 /index.php

Answer Source

You can set your a route for each url:

In your config/routes.php file, just set each page like this:

$route['ci/home'] = "ci/site_controller/home";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download