什么会导致 PHP 变量被服务器重写?
我的公司给了我一个虚拟机来安装网络软件。但我遇到了一个相当奇怪的问题,如果 PHP 变量与特定模式匹配,服务器就会覆盖(重写)它们。什么可以像这样重写 PHP 变量?
以下是一个完整的独立脚本。
<?php
$foo = 'b.domain.com';
echo $foo; // 'dev01.sandbox.b.domain.com'
$bar = 'dev01.sandbox.domain.com';
echo $bar; // 'dev01.sandbox.sandbox.domain.com'
$var = 'b.domainfoo.com';
echo $var; // 'b.domainfoo.com' (not overwritten because it didn't match whatever RegEx has been set)
?>
本质上,任何包含子域并与域名匹配的变量都将被重写。这不是 mod_rewrite 能够触及的东西,所以它必须是服务器级别的东西,解析 PHP 并重写字符串(如果它与正则表达式匹配)。
I was given a VM at my company to install web software on. But I came across a rather bizarre issue where PHP variables would be overwritten (rewritten) by the server if they matched a specific pattern. What could rewrite PHP variables like this?
The following is as an entire standalone script.
<?php
$foo = 'b.domain.com';
echo $foo; // 'dev01.sandbox.b.domain.com'
$bar = 'dev01.sandbox.domain.com';
echo $bar; // 'dev01.sandbox.sandbox.domain.com'
$var = 'b.domainfoo.com';
echo $var; // 'b.domainfoo.com' (not overwritten because it didn't match whatever RegEx has been set)
?>
Essentially any variable which contains a subdomain and matches on the domain name would be rewritten. This isn't something mod_rewrite would be able to touch, so it has to be something at the server level that is parsing out PHP and rewriting a string if it matches a RegEx.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Apache 中可以使用 mod_perl: PerlOutputFilterHandler 进行输出覆盖。
可以将以下内容添加到 apache.conf 中以设置输出过滤器:
示例过滤器处理程序代码:
有关 Apache mod_perl 过滤器的更多信息可以在此处找到: mod_perl:输入和输出过滤器
Output overwriting is possible within Apache by using mod_perl: PerlOutputFilterHandler.
The following could be added to an apache.conf to set the output filter:
Example filter handler code:
More on Apache mod_perl filters can be found here: mod_perl: Input and Output Filters