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