[英]Mod_security 406 with a '~' in the URL
I get a 406 Not Acceptable error while having a URL similar to this: 我收到一个406不可接受的错误,同时具有类似于以下的URL:
www.example.com/search/find?q=YSBkZXJwIGZyb20gZGVycA~
and it seems to be due to the singular ~
character. 而且似乎是由于~
字符。 I have to base64_encode()
it, using this function: 我必须使用以下函数将它设置为base64_encode()
:
function base64_url_encode($string = null) {
return strtr(base64_encode($string), '+/=', '-_~');
}
Because the normal base64 encode generates an un-parseable URL. 因为普通的base64编码会生成无法解析的URL。
I've had a look around and came across this answer: PHP/Apache Error:406 Not Acceptable 我环顾四周,并遇到以下答案: PHP / Apache错误:406不可接受
Which says to disable Mod_Security with: 这说禁用Mod_Security与:
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
I know I'll have to probably find a different rewrite for the function above, but how could I fix this as to not receive the error again, if there is any way? 我知道我可能必须为上面的函数找到一个不同的重写,但是如果有任何办法,我如何解决这个问题以免再次收到错误?
Instead of replacing =
characters with ~
, just remove them entirely. 无需将=
字符替换=
~
,只需将其完全删除即可。 This is a common approach , and will not prevent values from being decoded. 这是一种常见方法 ,不会阻止对值进行解码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.