[wp-hackers] Why WP_SITEURL and not $_SERVER['HTTP_HOST']?

Mike Little wordpress at zed1.com
Tue Mar 30 21:19:07 UTC 2010


On 30 March 2010 22:06, Mike Schinkel <mikeschinkel at newclarity.net> wrote:

> On Mar 30, 2010, at 7:19 AM, Mike Little wrote:
> > On 30 March 2010 11:32, Mike Schinkel <mikeschinkel at newclarity.net>
> wrote:
> >> The follow up is: Why then don't we just store "a/b/c/d/" to WP_SITEPATH
> >> and you get the domain from $_SERVER['HTTP_HOST'] and the port from
> >> $_SERVER['SERVER_PORT']?  (we can hardcode the "http(s)", that's okay.
> :-)
> >
> > Because a/b may be the site url (and c/d a page name), or it may be
> a/b/c;
> > there's no way of knowing until it's manually set up.
>
> If it's "a/b", set it as "a/b."  My question *assumed* it was "a/b/c/d"
> based on your comment and not "a/b."
> OTOH, my question really asked why must it be set to "
> http://example.com/a/b" or "http://example.com/a/b/c/d" instead of just
> "a/b" or "a/b/c/d."  The distinction between "a/b" and "a/b/c/d" is not
> relevant to the question.
>
> > There are (perhaps 'were' now ) places in both WP and WPMU that assumed
> no
> > port number, and, in WPMU, that assume only http.
>
> Then don't set the port number and assume http, that's easy.  Neither of
> those affect the question which is "why force the domain portion of
> WP_SITEURL to be set?"
>
>
So what you really need is not site url but a separate setting for domain of
a site, which could be auto adjusted when moved to a different domain. Which
is a different thing from the current 'siteurl' option.

WPMU does something a little like that, where the domain and path part are
separate (in order to support multiple domains and subdirectories. Perhaps
some of that has gone into WP 3.0?



> >
> > I've already written some code like this for a pre-packaged and populated
> WP
> > install, and the *first time* it got used it was installed on
> > http://ip.add.re.ss:5017/wrong-path/ -- my code didn't work at all!
>
>  Sorry, but I'm very confused by the anecdote and would like to understand
> it better.
>
>

My anecdote was merely to illustrate that the code to automatically detect
and adjust settings for moving an existing site to a new domain needs to be
quite sophisticated as, in theory, it may need to cope with someone moving
to an installation using an IP address and a non standard port number.


Mike
-- 
Mike Little
http://zed1.com/


More information about the wp-hackers mailing list