CodeIgniter - 删除“索引”来自网址 [英] CodeIgniter - Remove "Index" From URL
本文介绍了CodeIgniter - 删除“索引”来自网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
注意:我不是说要移除
index.php
- 我的意思是index
NOTE: I'm not talking about removing
index.php
- I meanindex
- 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
我该怎么做?
提前感谢!
推荐答案
您可以为此设置路由, application / config / routes.php
,添加新行:
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';
这将路由您的URL http://url.com/view- topic / anythinggoeshere
将掩盖查看主题/ index / anythinggoeshere
控制器。
This will route your URL http://url.com/view-topic/anythinggoeshere
will mask the view-topic/index/anythinggoeshere
controller.
有关路由的更多信息:
- Routing with Codeigniter
这篇关于CodeIgniter - 删除“索引”来自网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文