Codeigniter路由不工作有时 [英] Codeigniter routes not working sometimes

查看:96
本文介绍了Codeigniter路由不工作有时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题。我使用Codeigniter 2.1.0和我在我的routes.php下面的代码。

I have a little question. I am using Codeigniter 2.1.0 and I have the following code in my routes.php.

$route['default_controller'] = "photo";
$route['404_override'] = 'error';

$route['photo/:num'] = 'photo/index/$1';
$route['people/:num'] = 'people/index/$1'; 

奇怪的是,有时候我去 http://www.myurl.com/photo/1 它的工作原理,其他时候它会将我重定向到我的错误页面。

The weird thing is, sometimes when I go to http://www.myurl.com/photo/1 it works and othertimes it redirects me to my error page.

任何人都知道我的路线有什么问题?

Anyone maby has any idea what is wrong with my routes ?

提前感谢!

鲍勃

推荐答案

这不正确

$route['photo/(:num)'] = 'photo/index/$1';
$route['people/(:num)'] = 'people/index/$1'; 

您必须写此路线

$route['photo/(:num)'] = 'photo/$1';
$route['people/(:num)'] = 'people/$1'; 

这样只允许数字。

索引不是必需的。

这篇关于Codeigniter路由不工作有时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆