CodeIgniter - Remove “Index” From URL

2019-01-27 23:10发布

NOTE: I'm not talking about removing index.php - I mean index - the method name.

My current URL looks like this:

www.mysite.com/view-topic/index/my-topic

This is what I want it to look like:

wwww.mysite.com/view-topic/my-topic

How would I go about doing this?

Thanks in advance!

1条回答
祖国的老花朵
2楼-- · 2019-01-27 23:28

You can set up the routes for this, in application/config/routes.php, add a new line:

$route['view-topic/(:any)'] = 'view-topic/index/$1';

This will route your URL http://url.com/view-topic/anythinggoeshere will mask the view-topic/index/anythinggoeshere controller.

More information on routing:

查看更多
登录 后发表回答