duanpa5237 2013-01-02 21:52
浏览 39
已采纳

_SERVER值不等于其报告 - STRANGE

So there is this dedicated proxy server (rtrk.com) that has a subdomain proxy set up for one of the sites that I'm responsible for.

The following example is how it works
Original site: example.com
Proxy site: example-px.rtrk.com

When the proxy site url is accessed the original site is loaded in real time. Changes made to site files on the actual site are immediately shown via the proxy URL.

I've modified the site header to check the $_SERVER["SERVER_NAME"] value to make sure that it ends in example.com but the behavior I'm getting is far beyond what I would consider strange, take the following code for example:

$test = $_SERVER["SERVER_NAME"];
echo $test . "<br />";
echo stristr($test, "exam") . "<br />";
echo $test;
exit;

The following output is what I expect to see: (Accessed via proxy)

example-px.rtrk.com
example-px.rtrk.com
example-px.rtrk.com

What I actually see:

example-px.rtrk.com
example.com
example-px.rtrk.com

What the hell is going on here? I verify that $test is set to the correct value of the proxy host. stristr returns a completed value that is not actually even found in the original value I then re-verify that test has not somehow changed and it has not.

This is driving me absolutely insane! How is this possible?

EDIT:

I'm able get the correct output by manually setting the test variable to the string that SERVER_NAME is reporting. Example:

$test = "example-px.rtrk.com";
echo $test . "<br />";
echo stristr($test, "exam") . "<br />";
echo $test;
exit;

This is what I get (And expect to get):

example-px.rtrk.com
example-px.rtrk.com
example-px.rtrk.com
  • 写回答

2条回答 默认 最新

  • douhan8581 2013-01-02 23:22
    关注

    LOL - It's always something stupid when I cant figure it out.

    The problem is that when I access the site via the proxy, all data matching "www.example.com" is automatically converted to the proxy address on the fly before its returned to my browser.

    So long story short, everything was working the way it was suppose to, just the output was being modified before it reached my browser by the proxy server.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退