我正在构建一个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 here上提到的语言。
但是现在最后一条路线没能正常运作。
$route['(:any)'] = "url/go/$1";
例如,myshortner.com/as34v
应与上述路由匹配并重定向到完整网址,而是重定向到0.0.0.1
!我该如何解决这个问题?
答案 0 :(得分:0)
首先,你应该有一个带有“go”功能的URL控制器,该参数保持$ 1的参数。确保存在。