Support » Plugin: WPtouch » [Plugin: WPtouch] HTTP_HOST vs SERVER_NAME

  • Hello

    It the code of plugin, function bnc_filter_iphone() you have the following code:
    $redirect_location = $protocol . $_SERVER[‘HTTP_HOST’] . $_GET[‘wptouch_redirect’];
    header( ‘Location: ‘ . $redirect_location );

    It won’t work if the server name is not the same as the host name. It happens at some servers (for example, default Nginx is configured like I said). Why don’t you use

    $redirect_location = $protocol . ($_SERVER[‘HTTP_HOST’] ?: $_SERVER[‘SERVER_NAME’]) . $_GET[‘wptouch_redirect’];



Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author BraveNewCode Inc.


    What version are you referring to? Our latest version doesn’t match what you’re showing.


    I’m using WPtouch 1.9.40.

    The following code is in the 540th. line of wptouch.php in WPtouch version 1.9.40:
    $redirect_location = $protocol . $_SERVER[‘SERVER_NAME’] . $_GET[‘wptouch_redirect’];

    It doesn’t work in php-fcgi with nginx as the front end.
    Because php-fcgi doesn’t know $_SERVER[‘SERVER_NAME’].

    The following code works.
    $redirect_location = $protocol . ($_SERVER[‘HTTP_HOST’] ?: $_SERVER[‘SERVER_NAME’]) . $_GET[‘wptouch_redirect’];


    Damn, I have mixed them. Being too sleepy. 🙂

    For now I am using the following fix:

    # grep -A7 funny /etc/nginx/fastcgi_params
    # The funny thing
    if ($http_host ~ ^(.+)$) {
    set $name $http_host;
    if ($http_host ~ ^$) {
    set $name $server_name;
    fastcgi_param SERVER_NAME $name;

    So, as you see, we’re preferring $http_host to $server_name.

    But I still don’t think that it is a good idea to tie the code to the name of the server. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WPtouch] HTTP_HOST vs SERVER_NAME’ is closed to new replies.