duandan9680
2016-08-01 16:13
浏览 69
已采纳

在CodeIgniter中混合静态和动态页面

I'm trying to mix static and dynamic content in a CodeIgniter 3.1 tailored website. I'm using the tutorial example given for the static content:

$route['default_controller'] = 'pages/view';
$route['(:any)'] = 'pages/view/$1';

I'm afraid this would be quite messy for the purpose, since (:any) is too generic and I don't want to use something like "/static/(:any)" route.

Any suggestions on how to achieve a solution that let me have a static and controller named friendly URL?

Every idea is welcome and very much appreciated.


As my question seems to be difficult to understand, I'll try to ask it once again:

Is there a way to combine static content with the above code (from codeigniter tutorial) and the usual approach http://example.com/controller/index_named_method dynamic content handling?

Can you give an example?

Should I change $route['(:any)'] for every static webpage's name i.e.: $route['(home|contact|links)'] ?

Thanks in advance

图片转代码服务由CSDN问答提供 功能建议

我正在尝试在CodeIgniter 3.1定制的网站中混合静态和动态内容。 我正在使用为静态内容提供的教程示例:

  $ route ['default_controller'] ='pages / view'; 
 $ route ['(:any  )''='pages / view / $ 1'; 
   
 
 

我担心这会非常混乱,因为(:any)太通用了 我不想使用像“/ static /(:any)” route这样的东西。

有关如何实现解决方案的任何建议让我 有一个名为友好URL的静态和控制器吗?

欢迎提出任何想法,非常感谢。


正如我的问题 似乎很难理解,我会再试一次:

有没有办法将静态内容与上面的代码(来自codeigniter教程)和通常的方法相结合< 代码> http://example.com/controller/index_named_method 动态内容处理?

你能给出一个例子吗?

应该 我为每个静态网页的名称更改 $ route ['(:any)'] ,即: $ route ['(home | contact | links)']

提前致谢

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dtnd30892 2016-08-06 13:03
    已采纳

    Well, I must say that I got to an answer myself; as said in my previous post editing, mixing static and dynamic content using index() method in your Controller taking advantage of the tutorial example can be accomplished adding a route with all your controllers name like this:

    $route['(books|flowers|links)'] = '$1';

    Thanks to those who helped.

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题