如何隐藏控制器名称在CodeIgniter的网址? [英] How to hide controller name in the url in CodeIgniter?

查看:81
本文介绍了如何隐藏控制器名称在CodeIgniter的网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以事情是我使用.htaccess隐藏index.php,但我仍然得到控制器名称在url像这样: http://example.com/name_controller/about
我的问题是:是否可以隐藏控制器的名称,以便只显示方法? hxxp://example.com/name_controller/about

so the thing is I'm using .htaccess to hide the index.php but I still get the controller name in the url like that: http://example.com/name_controller/about My question is: is it possible to hide the name of the controller, so that only method is shown? hxxp://example.com/name_controller/about

推荐答案

您可以在config / routes.php中定义自定义路由 - 示例:

You can define a custom route in config/routes.php - for example:

$route['about'] = 'name_controller/about';

Then, http://example.com/about
goes to http://example.com/name_controller/about

请参阅隐藏控制器的方法名称在网址中?在CI论坛中了解更多信息。

See Hiding the controller’s method name in the URL? in the CI forums for more information.

这篇关于如何隐藏控制器名称在CodeIgniter的网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆