How to remove controller name and function from URL in CodeIgnitor

I have a serious problem with a single application developed in CI. Currently my urls are as follows

http://www.example.com/content/index/mission/

I want to remove / content / index / from the URL. Therefore, it should look something like this.

http://www.example.com/mission

I have a routing method and .htaccess. But nothing works.

Could you help me?

Here is my .htaccess file

Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteCond $1 !^(index\.php|images|css/js/style/system/feature_tab/robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [QSA,L] 

I also tried to route CI by specifying reouters in config / router.php. But it did not work: (

+2
source share
2 answers

In your specific example, you need to create a route (in application/config/routes.php ) that displays

 $route['mission/'] 

to

 "content/index/mission" 

In other words, $route['mission/'] = "content/index/mission";

Learn more about CI documentation regarding URI routing for more information.

+4
source

You can go into application / config / routes.php and set your own URL routing rules. (i.e. use something completely different than Controller / Funcction). There should be an array called $ route, which allows you to assign mappings url => controller / function. Hope this helps.

Check out this guide, its right to lane:

http://codeigniter.com/user_guide/general/routing.html

+1
source

Source: https://habr.com/ru/post/898955/


All Articles