wpXtreme/wpdk

Current URL

Closed this issue · 1 comments

In some server configurations (like linux with Cpanel and nginx) the method currentURL prepend the www. Use:

function get_host() {                                                                     
    if ($host = $_SERVER['HTTP_X_FORWARDED_HOST'])                                        
    {                                                                                     
        $elements = explode(',', $host);                                                  

        $host = trim(end($elements));                                                     
    }                                                                                     
    else                                                                                  
    {                                                                                     
        if (!$host = $_SERVER['HTTP_HOST'])                                               
        {                                                                                 
            if (!$host = $_SERVER['SERVER_NAME'])                                         
            {                                                                             
                $host = !empty($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '';   
            }                                                                             
        }                                                                                 
    }                                                                                     

    // Remove port number from host                                                       
    $host = preg_replace('/:\d+$/', '', $host);                                           

    return trim($host);                                                                   
}                                                                                         

Closed!!