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

  • 写回答

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果