url编码的正斜杠打破我的codeigniter应用程序 [英] url encoded forward slashes breaking my codeigniter app

查看:313
本文介绍了url编码的正斜杠打破我的codeigniter应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个工作如下的网址字符串:

i’m trying to create a url string that works like this:

/app/process/example.com/index.html

换句话说,

/app/process/$URL



具有

i then retrieve the url with

$this->uri->segment(3);

URL中的正斜杠当然是访问uri段的一个问题,所以我会去URL和URL编码URL部分:

the forward slashes in the URL will of course be a problem accessing uri segments, so i’ll go ahead and url encode the URL portion:

/app/process/example.com%2Findex.html

..但现在我只得到一个404 ... ...

.. but now I just get a 404 saying ...

Not Found

The requested URL /app/process/example.com/index.html was not found on this server. 

看来我的正斜杠的url编码打断了CI的URI解析器。

it appears that my url encoding of forward slashes breaks CI’s URI parser.

我可以怎么解决这个问题?

what can i do to get around this problem?

推荐答案

获取不是从codeigniter而是从您的Web服务器。

I think the error message you are getting is not from codeigniter but from your web server.

我使用Apache2甚至不使用CodeIgniter复制这个:我创建了一个文件index.php,然后访问 index.php / a / b / c - 它工作正常。如果我然后尝试访问 index.php / a / b / c%2F 我从Apache获得了404。

I replicated this using Apache2 without even using CodeIgniter: I created a file index.php, and then accessed index.php/a/b/c - it worked fine. If I then tried to access index.php/a/b/c%2F I got a 404 from Apache.

我通过添加到我的Apache配置解决了:

I solved it by adding to my Apache configuration:

AllowEncodedSlashes On

请参阅文档了解更多信息

一旦你这样做了,你可能需要用 $ config ['permitted_uri_chars'] codeigniter如果它仍然不工作 - 你可能会发现斜线被过滤掉

Once you've done this you might need to fiddle around with $config['permitted_uri_chars'] in codeigniter if it is still not working - you may find the slashes get filtered out

这篇关于url编码的正斜杠打破我的codeigniter应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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