WordPress.org

Ready to get started?Download WordPress

Forums

WPtouch Mobile Plugin
[Plugin: WPtouch] HTTP_HOST vs SERVER_NAME (4 posts)

  1. dinexi
    Member
    Posted 2 years ago #

    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'];

    ?

    Regards,
    Stanis

    http://wordpress.org/extend/plugins/wptouch/

  2. BraveNewCode Inc.
    Member
    Plugin Author

    Posted 2 years ago #

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

  3. river24
    Member
    Posted 2 years ago #

    Hello.

    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'];

    Regards,
    river24

  4. dinexi
    Member
    Posted 2 years ago #

    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. :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags