0

我正在建立一个 URL 缩短器网站。

这是我的config/routes.php文件:

$route['default_controller'] = "main";
$route['404_override'] = '';
$route['(\w{2})/(.*)']        = '$2';
$route['(\w{2})']             = $route['default_controller'];

$route['join']                = 'main/join';
$route['activate/(:any)']     = "main/activate/$1";
$route['login']               = 'main/login';
$route['logout']              = 'main/logout';
$route['main/login']          = 'main/login';
$route['main/join']           = 'main/join';
$route['url/short']           = 'url/short';
$route['user']                = 'user/index';
$route['user/index']          = 'user/index';
$route['user/index/(:num)']   = 'user/index/$1';
$route['profile']             = 'user/profile'; 
$route['user/delete/(:any)']  = "user/delete/$1";

$route['(:any)']              = "url/go/$1";

好吧,如您所见,我实现了 CI Wiki 中提到的语言

但是现在最后一行路线无法正常运行。

$route['(:any)']              = "url/go/$1";

例如,myshortner.com/as34v应该与上面的路由匹配并重定向到完整的 URL,但它会重定向到0.0.0.1! 我怎样才能解决这个问题?

4

1 回答 1

0

首先,您应该有一个带有“go”函数的 URL 控制器,该函数接受一个保存在 $1 中的参数。确保存在。

于 2012-11-08T15:48:11.600 回答