代码点火器路由 [英] code igniter routing
问题描述
我想解决程式码启动器路由
我有一个看起来像
我想要点击
http://example.com/account/register/normal
我也有
http ://example.com/invite/something_random_here
我想点击
a href =http://example.com/account/register/invite/something_random_here =nofollow> http://example.com/account/register/invite/something_random_here
http://example.com/account/register/invite/something_random_here
我也有
http://example.com/register/something_random_here
我想点击
http://example.com/account/register/subscribed/something_random_here
如何设置这些路线?
推荐答案
http://codeigniter.com/user_guide/general/routing.html =nofollow>直接使用用户指南
Pretty much Straight out of the User Guide
$route['register'] = "account/register/normal";
$route['invite/(:any)'] = "account/register/invite/$1";
基本上邀请/
后,到 account / register / invite
的结尾。我相信它只适用于一个细分,如果你想要多个细分支持,你必须使用正则表达式:
Basically anything after invite/
will get tacked onto the end of account/register/invite
. I believe it only works for one segment, if you want multiple segment support you'll have to use a regular expression:
$route['invite/(.+)'] = "account/register/invite/$1";
另一个有用的(因为我相信(:any)
仅适用于字符)将是:
Another usefull one (because I believe (:any)
only works for characters) would be:
$route['invite/([a-zA-Z0-9_-]+)'] = "account/register/invite/$1";
这将让所有的字母数字值GUID:)
This will let all alpha-numeric values (single segment) with _ or - go through, great for GUIDs :)
这篇关于代码点火器路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!