在codeigniter中创建动态网址 [英] Creating dynamic urls in codeigniter
问题描述
我目前正在为通讯社制作小型CMS。管理员将在一段时间内更新新闻。现在我想让 url
看起来像 http://somedomain.com/apple-iphoe5c-released
,而不是例如 http://somedomain.com/top-news/1
。我在 gocart
(内置codeigniter)中看到,他们有产品名称的url。
对于这个东西,你使用ci中的路由
考虑一个小例子
$ route ['aboutus'] =任何控制器映射到该名称;
samplesite.com/aboutus [aboutus is controller] samplesite.com/contactus [contactus is controller]
$ route ['memberaccount /(:num)'] =任何控制器映射到该名称/ $ 1;
samplesite.com/memberaccount/32
如果仍然无法尝试上述链接 http://ellislab.com/codeigniter/user -guide / general / routing.html
I am currently making a small CMS for a news agency. The admin will update the news in a interval of time. Now I want the url
to be look like http://somedomain.com/apple-iphoe5c-released
, not like http://somedomain.com/top-news/1
. I have seen in gocart
( built in codeigniter ) , they have the url with the product name . How I am able to achieve this ?
for this thing you have use the routes in ci which are as given
Consider the small example $route['aboutus'] = "any controller is map to that name";
samplesite.com/aboutus [aboutus is controller] samplesite.com/contactus [contactus is controller]
$route['memberaccount/(:num)'] = "any controller is map to that name/$1";
samplesite.com/memberaccount/32
if still not getting try the above link http://ellislab.com/codeigniter/user-guide/general/routing.html
这篇关于在codeigniter中创建动态网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!