[wp-trac] [WordPress Trac] #41661: Using proxy & HTTP 1.1 leads to full URL in REQUEST_URI variable in Apache
WordPress Trac
noreply at wordpress.org
Thu Aug 17 15:29:39 UTC 2017
#41661: Using proxy & HTTP 1.1 leads to full URL in REQUEST_URI variable in Apache
--------------------------+-----------------------------
Reporter: olygraph | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.8.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
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
<?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;
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41661>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list