涉及查询的Codeigniter路由问题 [英] Trouble with Codeigniter Routes involving a query

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

问题描述

在URI中有一个查询(在?之后的内容)时,我对CodeIgniter路由有点麻烦。我知道这是一个很好的做法,用CI中的路由替换查询,但我正在导入一个预制的留言板,已经做了一切与查询。这是我的路线:

I'm having a little trouble with a CodeIgniter route when there is a query (stuff after the ?) in the URI. I know it is good practice to replace queries with routes in CI, but I'm importing in a premade messageboard that already does everything with queries. This is my route:

$ route ['messageboard /:any'] =messageboard / index;

$route['messageboard/:any'] = "messageboard/index";

任何在这种情况下指的是脚本名称。所以如果它的messageboard / admin.php,我加载一个视图加载我的预制留言板的脚本admin.php。它的工作很好,如果我做messageboard / admin.php。如果我做messageboard / admin.php?然而,如果我把一个参数到查询,路由将不会正确地发送用户到留言板控制器,而是将它们发送到404.有谁有任何想法如何使这项工作?我会永远感激。谢谢!

Any in this case refers to a script name. So if it's messageboard/admin.php, I have it load a view that loads my premade messageboard's script "admin.php". It's working just fine if I do messageboard/admin.php. It does fine if I do messageboard/admin.php?. If I put a parameter into the query, however, the route won't correctly send the user to the messageboard controller, and instead sends them to a 404. Does anyone have any ideas on how to make this work? I would be eternally grateful. Thanks!

推荐答案

好吧,我解决了。我需要改变三件事。第一个是mtvee的建议,它让它读取查询字符串。第二个你想改变$ config ['permitted_uri_chars']在配置文件中包含一个等号,因为它开始禁用,所有的查询字符串将是for?a = 34或类似的东西那。第三个是你需要去$ config ['uri_protocol'],并将其从AUTO更改为PATH_INFO。一旦我这样做,它的工作。

Okay guys, I solved it. I needed to change three things. The first was mtvee's suggestion, which lets it read query strings. The second one you're going to want to change the $config['permitted_uri_chars'] in the config file to include an equals sign, since it starts off disabled and all query strings will be of the for ?a=34 or something like that. The third is you need to go to $config['uri_protocol'] and change it from AUTO to PATH_INFO. Once I did those, it worked.

这篇关于涉及查询的Codeigniter路由问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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