CodeIgniter:URI段中的Urlencoded URL不起作用 [英] CodeIgniter: urlencoded URL in URI segment does not work
问题描述
我正在尝试将URL作为CI中URI段之一的值。我的控制器方法已定义为接受此类参数。但是,当我转到URL时,出现404错误。例如:
I'm trying to put a URL as the value of one of my URI segments in CI. My controller method is defined to accept such an argument. However, when I go to the URL, I get a 404 error. For example:
www.domain.com/foo/urlencoded-url /
www.domain.com/foo/urlencoded-url/
有什么想法吗?我应该通过GET代替吗?
Any ideas what's wrong? Should I do this via GET instead?
更新:
//会产生404
http:// localhost / myapp / profile_manager / confirm_profile_parent_delete / ugpp_533333338 / http%3A%2F%2Flocalhost%2Fmyapp%2Fdashboard%2F
// URL that generates 404
http://localhost/myapp/profile_manager/confirm_profile_parent_delete/ugpp_533333338/http%3A%2F%2Flocalhost%2Fmyapp%2Fdashboard%2F
//这是在我的 profile_manager
控制器中
公共功能Confirm_profile_parent_delete($ encrypted_user_group_profile_parent_id ='',$ url_current = '')
// This is in my profile_manager
controller
public function confirm_profile_parent_delete($encrypted_user_group_profile_parent_id = '', $url_current = '')
如果删除第二个URI段,则不会显示404: http:// localhost / myapp / profile_manager / Confirm_profile_parent_delete / ugpp_533333338 /
If I remove the second URI segement, I don't get a 404: http://localhost/myapp/profile_manager/confirm_profile_parent_delete/ugpp_533333338/
推荐答案
似乎%2F破坏了Apache的功能。
It seems that the %2F breaks things for apache.
可能的解决方案:
- preg_将/替换为-(或其他东西) ),然后再将其发送到另一端。
- 将apache设置为AllowEncodedSlashes On
- 有点黑,但您甚至可以s将网址保存为会话变量或其他内容,而不是通过网址发送*耸肩*
- 在发送前先对它进行双重编码
- preg_replace the /'s to -'s (or something else) before sending the url then switch it back on the other end.
- Set apache to AllowEncodedSlashes On
- bit of a hack, but you could even save the url to a session variable or something instead of sending through the url *shrug *
- double url encode it before sending
这篇关于CodeIgniter:URI段中的Urlencoded URL不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!