【问题标题】:Controllers slugs [closed]控制器蛞蝓[关闭]
【发布时间】:2012-10-05 13:44:03
【问题描述】:

我正计划开发中型网站。我想使用 SEO 友好的 url 之类的

http://foobar.com/category/fun/
http://foobar.com/article/lorem-ipsum.html

如您所见,我想使用 slugs 作为控制器名称。 我打算通过以下方式实现它。

一个文件处理所有请求。

在 routes.php 中

$route['(:any)'] = 'my_routes/$1';

然后在带有 $this->uri->segment 的 my_routes 中,我可以确定请求哪个控制器。

对整个网站只使用一个文件 (my_routes) 是个好主意吗?

你能给我推荐一些更好的解决方案吗?

【问题讨论】:

    标签: php codeigniter routes


    【解决方案1】:

    是的,这是个不错的决定。我在我的项目中做同样的事情,所有路由都通过 index.php 和 .htaccess 文件配置为发送 index.php 上的所有 URL。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-24
      • 2011-05-12
      • 2017-11-05
      • 2016-04-21
      • 2014-07-30
      • 2016-06-02
      相关资源
      最近更新 更多