Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have getting variable results from the $_SERVER['HTTP_HOST'] variable in the functions.php file of our child theme.

Let me explain our setup and then I'll explain the issue. We are running WP 3.5.2 on Nginx with PageLines 2.4 as our parent theme and a handful of plugins that I can detail if necessary. Our virtual host is set to answer to *.salesgenie.com as we have several private label subdomains that will change the branding of the site. www.salesgenie.com will be the generic domain but att.salesgenie.com is an example of a branded subdomain.

So I need to be able to detect the subdomain the client calls with which I am trying to get with $_SERVER['HTTP_HOST']. The issue is that $_SERVER['HTTP_HOST'] is accurate the first time a client comes to their domain but reverts to the $_SERVER['SERVER_NAME'] value after that either on page reload or navigation to any other page. Any ideas why this might happen or how to work around it?

To test this I've got a function logging the $_SERVER['SERVER_NAME'] and $_SERVER['HTTP_HOST'] to a cookie called CmsCookie and you can test it by going to cms.salesgenie.com (the CNAME is working) and both variables will read cms.salesgenie.com. But if you modify your host file to point att.salesgenie.com at 54.208.87.200 then you can test att.salesgenie.com and the cookie will be correct the first time you hit a page, but if you reload, both server name and host will be cms.salesgenie.com

share|improve this question
    
WordPress only changes the value of HTTP_HOST in the \wp-includes\ms-settings.php file. Specifically, it strips the port if :80 or :443 are in the url. If your parent theme and the plugins are not changing this value, this may not be a WordPress question. –  Charles Clarkson Aug 7 '13 at 16:27
    
Well I'll copy our installation to our test environment and see if switching themes or disabling plugins does anything. –  Robert Aug 7 '13 at 16:31
1  
Alrighty then. It is a PageLines theme issue since when I switch to TwentyTwelve I get the proper value for HTTP_HOST. –  Robert Aug 7 '13 at 18:36
    
I only scanned the code, but look a the result of pl_get_uri( true ); –  Charles Clarkson Aug 7 '13 at 21:04
    
It's behaving the same as HTTP_HOST. Fine on the first visit to the url, but then rest to SERVER_NAME after that. –  Robert Aug 8 '13 at 18:26
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.