URL 中的 %2F 中断并且不引用所需的 .php 文件 [英] %2F in URL breaks and does not reference to the .php file required
问题描述
我需要将/作为变量作为 URL 的一部分传递.
I need to pass / as a variable as part of a URL.
我的结构是这样的:www.domain.com/listings/page-1/city-Burnaby+South/type-Townhome/bedroom-2/bathroom-2
My structure looks like this: www.domain.com/listings/page-1/city-Burnaby+South/type-Townhome/bedroom-2/bathroom-2
在这种情况下,它最终归结为 listings.php,除此之外的所有其他内容都成为我的 PHP 脚本通过使用 $_SERVER['REQUEST_URI'] 变量解析的参数.
In this case, it ultimately boils down to listings.php and everything else beyond it becomes parameters taht my PHP script parses through using the $_SERVER['REQUEST_URI'] var.
但是,当生成 URL 时,当 hte 变量之一变为公寓/公寓"且/变为 %2F 时,通过 PHP 中的 urlencode() 变为 %2F,整个过程就会窒息,并且出现未找到"错误.
However when one of hte variables becomes "Apartment/Condo" and the / becomes %2F via urlencode() in PHP when the URL is generated, the whole thing chokes and I get a "Not Found" error.
如何在不破坏 URL 的情况下传递/?我错过了什么?我认为这些 urlencode() 字符(%2F、%20 等)的全部意义在于逃避这些问题.
How do I pass the / without breaking the URL? What am I missing? I thought the whole point of these urlencode() characters (%2F, %20 etc.) were there to escape these issues.
推荐答案
Urls with %2f /
or %5c \
出于安全目的,从 Apache
返回 404.
Urls with %2f /
or %5c \
return a 404 from Apache
for security purposes.
您可以修改 Apache 配置以启用 AllowEncodedSlashes On
或 NoDecode
.请记住,这可能会引入意外的安全问题,而此功能"旨在缓解这些问题.
You may modify Apache config to enable AllowEncodedSlashes On
or NoDecode
. Keep in mind that this may introduce unintended security issues, which this "feature" is designed to mitigate.
Apache 文档:http://httpd.apache.org/docs/current/mod/core.html#allowencodedslashes
已解决:
这个也吸引了我——谢谢你的问题
This one got me too -- thanks for the question
这篇关于URL 中的 %2F 中断并且不引用所需的 .php 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!