Make WordPress Core

Opened 7 years ago

Closed 5 years ago

Last modified 5 years ago

#41661 closed defect (bug) (duplicate)

Using proxy & HTTP 1.1 leads to full URL in REQUEST_URI variable in Apache

Reported by: olygraph's profile olygraph Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

When using a proxy the browser send a full URL in var REQUEST_URI
$_SERVER['REQUEST_URI'];

i.e.:

With proxy: it returns http://mydomain.com/requestedurl
No Proxy: it returns /requestedurl

Solution:
check the variable to see if it is full path and transform it:

<?php

$_SERVER['REQUEST_URI'] = requesturl_format($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']);
    
    function requesturl_format($m_host, $m_request){
        $m_regex = sprintf('#(https?://)(%s)(/.*)#', $m_host);
    
        if(preg_match( $m_regex, $m_request, $matches)){
                if(count($matches) == 4){
    
                        $m_host = ($matches[1]);
                        $m_domain = ($matches[2]);
                        $m_url_req = ($matches[3]);
                        return $m_url_req;
                }
        }
        return $m_request;
    }

Change History (3)

#1 @swissspidy
7 years ago

  • Keywords reporter-feedback added

Hey there,

Thanks for your report and welcome to Trac. This sounds like a duplicate of #17047. Can you confirm this?

#2 @ocean90
5 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version 4.8.1 deleted

Duplicate of #17047.

#3 @SergeyBiryukov
5 years ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.