您如何配置 Apache/PHP 以接受查询字符串中的斜杠? [英] How do you configure Apache/PHP to accept slashes in query strings?

查看:37
本文介绍了您如何配置 Apache/PHP 以接受查询字符串中的斜杠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两台运行 PHP 的 Apache 服务器.接受查询字符串中的正斜杠并以预期的方式将其传递给 PHP,例如:

<前>http://server/index.php?url=http://foo.bar

有效并且在 PHP 中此表达式为真:

$_REQUEST['url'] == "http://foo.bar"

然而,在 other Apache 服务器中,相同的 URL 会导致 403 Forbidden 错误!请注意,如果查询字符串是正确的 URL 转义(即使用 %2F 而不是正斜杠),则一切正常.

很明显,导致这种情况的 Apache 或 PHP 配置存在一些差异,但我不知道是什么!

我想在两种情况下接受这种形式的 URL,而不是拒绝它.

解决方案

http://server/index.php?url=http://foo.bar 不是有效的 url.您必须对斜杠进行编码.我认为浏览器会自动执行此操作,所以您可能正在使用不同的浏览器进行测试?

或者可能是 AllowEncodedSlashes 设置?>

I have two Apache servers running PHP. One accepts forward-slashes in the query string and passes it along to PHP in the expected way, for example:

http://server/index.php?url=http://foo.bar

works and in PHP this expression is true:

$_REQUEST['url'] == "http://foo.bar"

However, in the other Apache server, the same URL results in a 403 Forbidden error! Note that if the query string is properly URL-escaped (i.e. with %2F instead of forward-slash), then everything works.

Clearly there's some difference in the Apache or PHP configuration that causes this, but I can't figure out what!

I want to accept this form of URL in both cases, not reject it.

解决方案

http://server/index.php?url=http://foo.bar is not a valid url. You have to encode the slashes. I think browsers do this automagically, so maybe you were testing with different browsers?

Or perhaps it's the AllowEncodedSlashes setting?

这篇关于您如何配置 Apache/PHP 以接受查询字符串中的斜杠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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