【问题标题】:More than just friendly urls不仅仅是友好的网址
【发布时间】:2013-07-26 06:52:02
【问题描述】:

这里收集了一些 URL,我想知道,如何使用 Codeigniter 来激活这样的结果,它们叫什么?

  1. exemple.com/movies/action/some-title-that-i-want-to-implement/(带来帖子)
  2. exemple.com/movie-name/some-title-that-i-want-to-implement/(附上具体帖子)
  3. exemple.com/movie-name(包含所有电影帖子)
  4. exemple.com/comic-con/movies/some-title-that-i-want-to-implement/(带来帖子)
  5. exemple.com/comic-con/comics/some-title-that-i-want-to-implement/(带来帖子)
  6. exemple.com/some-title-that-i-want-to-implement/(带来帖子)
  7. exemple.com/2013/7/26/4558760/some-title-that-i-want-to-implement/(带来一个帖子)

最大的问题是您如何组织和认为您的应用程序具有相似的结果?

【问题讨论】:

    标签: php .htaccess codeigniter friendly-url codeigniter-routing


    【解决方案1】:

    如何使用 Codeigniter 来激活这样的结果? Juat 玩这些:

    1. _remap() 控制器中的函数
    2. URI Class
    3. 路由配置。

    例子:

    exemple.com/movies/action/some-title-that-i-want-to-implement/(带来 一个帖子)

    假设您的默认控制器是home;然后:

    config/routes.php:

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

    控制器/home.php

    class Home extends CI_Controller {
    
        function index()
        {
            //do somthing
        }
    
        public function _remap()
        {
           //play with uri segment here, i.e:
           if ($this->uri->segment(1) == 'movies')
           {
             //take 'movies' as parameter and use it
           }
           else
           {
            //you can be more creative than me
           }
        }
    }
    

    它们叫什么?我不确定,我猜是“虚拟 URI 映射”。

    您如何组织并认为您的应用程序具有相似的结果? 没有什么特别的。

    【讨论】:

    • 谢谢,我试试
    猜你喜欢
    • 2012-10-15
    • 2011-02-15
    • 2010-12-28
    • 2016-03-11
    • 1970-01-01
    • 2010-09-11
    • 2011-07-23
    • 2011-04-06
    • 2014-01-14
    相关资源
    最近更新 更多