Make WordPress Core

Opened 6 years ago

Last modified 6 years ago

#44251 new defect (bug)

Wrong way of getting website root url when site is rewritten

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


I have my wordpress setup on IIS and it is on This is "real" address of my website. However user see this url Every page works but my homepage goes in redirect loop. I made changes to my wordpress settings and I setup that my site url is Inside web.config file of project I made rewrite rule. This is about my setup. Now about where is problem. Problem is in wp_includes/canonical.php file inside redirect_canonical method:
if ( ! $requested_url && isset( $_SERVERHTTP_HOST? ) ) {

build the URL in the address bar
$requested_url = is_ssl() ? 'https://' : 'http://';
this is wrong in my opinion, this returns, and not, causing problem of infinite redirection loop, probably some code compares this incoreectly made $requested_url variable with something else

$sURL = site_url();

$asParts = parse_url( $sURL );

$requested_url .= $asPartshost? ;

This 3 lines above are how I solved my problem.So I deleted this line:$requested_url=$_SERVERHTTP_HOST?; and put those 3 line above instead

Change History (2)

#1 @subrataemfluence
6 years ago

As far as I know web.config is used for .NET projects!

#2 @vladop
6 years ago

Web config is used for .NET project. I have .NET project at
and it's web config is used for all links on that domain. My wordpress blog is "underneath" that domain at but only because I rewritten it. It has to be at but in fact it is on another server with this link: You can imagine it is on this url: but it has to be rewritten to:
Idea here is that redirect_canonical gets site root url using HTTP_HOST variable but not site url root. They don't have to match.

Note: See TracTickets for help on using tickets.