[英]codeigniter route problem
result I want : 结果我想:
greeting/102/steve => greeting/index/102/steve
in greeting.php : 在greeting.php中:
function index($order,$name)
{
echo "order: $order , name : $name ! ";
}
in route.php : 在route.php中:
$route['greeting/(:num)/(:any)'] = "greeting/index/$1/$2";
result I get : 结果我得到:
order : , name : steve !
Actually, it's right to use double quotes. 实际上,使用双引号是正确的 。 It's even indicated like this in the manual (beside having done it a hundred times), so I don't see the problem @cwallenpool is pointing out. 它在手册中甚至表示如此(除了已经完成了一百次),所以我没有看到@cwallenpool指出的问题。
Your routing looks fine, be sure it is called after the reserved routes 您的路由看起来很好,请确保在保留路由后调用它
$route['default_controller'] = "welcome";
$route['404_override'] = '';
$route['greeting/(:num)/(:any)'] = "greeting/index/$1/$2";
. 。
I suggest you to try using $this->uri->rsegment(n)
(info on user guide here ) to catch the rerouted uri segment that's causing you trouble. 我建议你尝试使用$this->uri->rsegment(n)
( 这里的用户指南信息 )来捕获导致你麻烦的重新路由的uri段。 (similar to $this->uri->segment(n)
but designed specifically for rerouted URIs) (类似于$this->uri->segment(n)
但专门为重新路由的URI设计)
You can also try changing the $config['uri_protocol']
from AUTO to PATH_INFO (or one of the other alternatives) and see if the problem doesn't sit there. 您也可以尝试将$config['uri_protocol']
从AUTO更改为PATH_INFO(或其他替代方案之一),看看问题是否存在。 Remember also to delete the 'index.php' part in $config['index_page']
if you're using htaccess to delete the index.php from you URL. 如果您使用htaccess从URL中删除index.php,请记住还要删除$config['index_page']
的'index.php'部分。
I have recently written a library that can provide ease in such cases. 我最近写了一个可以在这种情况下轻松提供的库。 I pass the values to the required variables via name rather numbering. 我通过名称而不是编号将值传递给所需的变量。 Also the names are included in routes to easy reference them. 名称也包含在路线中以便于参考。
May be you can have a look at it, could be useful in your case. 也许你可以看看它,在你的情况下可能有用。
https://github.com/aajiwani/LaravelRoutingForCodeIgniter https://github.com/aajiwani/LaravelRoutingForCodeIgniter
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.