【发布时间】:2011-10-12 07:08:32
【问题描述】:
我想要
这些网址作为我页面上的类别:
http://example.com/en/articles //for list of all
http://example.com/en/articles/cars //for list of all cars articles
http://example.com/en/articles/nature //for list of all nature acrticles
http://example.com/en/articles/sport //for list of all sport articles
我正在使用 i18n,这就是为什么我还有其他链接,例如:
http://example.com/fr/articles //for list of all
http://example.com/fr/articles/cars //for list of all cars articles
http://example.com/fr/articles/nature //for list of all nature acrticles
http://example.com/fr/articles/sport //for list of all sport articles
这很简单,我在里面调用了一个控制器articles.php anf 我有汽车、自然、运动等功能,一切都很好。
但是,我想要文章,不管它们是什么类别,像这样:
http://example.com/en/articles/article-about-cars http://example.com/en/articles/article-about-nature
所以,当查看全文时,该类别从 url 中消失了。
我使用的是 i18n,所以我的路线如下所示:
$route[’^en/articles/(.+)$’] = “articles/show_full_article/$1”;
$route[’^fr/articles/(.+)$’] = “articles/show_full_article/$1”;
但每次调用函数 show_full_article 时都会调用它,因为它在第 2 段中。
所以,我需要在以下位置重建正则表达式:
$route['^en/articles/(.+)$'] = "articles/show_full_article/$1";
排除功能汽车、自然和运动。我只有 3 个类别,所以手动输入没什么大不了的。
如果您知道如何在 routes.php 中键入正则表达式以排除这三个类别,那么 codeigniter 不再将它们视为文章名称,请告诉我。我会非常感激的。
提前感谢您的任何建议。
【问题讨论】:
标签: php codeigniter