[wp-hackers] absolute URLs in plug-ins and custom types
Otto
otto at ottodestruct.com
Wed Jul 4 19:55:26 UTC 2012
On Wed, Jul 4, 2012 at 1:42 PM, Shasta Willson <shastaw at gmail.com> wrote:
> On Wed, Jul 4, 2012 at 11:32 AM, Bill Erickson <bill.erickson at gmail.com> wrote:
>> If the client asks you to move the site to a subdirectory, all your
>> relative links will be broken.
>
> Uh..no..that's what relative URLs are specifically for.
So, a URL of /2012/07/whatever will still work when you move it to
/blog/2012/07/whatever? (Hint: nope.)
If you're considering that a URL shouldn't be relative to the root (as
in not starting with a / character), then consider images in posts. If
the image is at /wp-content/uploads/whatever, then what will it's
relative URL be when it's displayed on both http://example.com/ and
http://example.com/2012/07/postname/? It can't be just
"wp-content/uploads/whatever", because it has to be
"../../../wp-content/uploads/whatever" for the second URL case.
Absolute URLs are the best solution to the problem of disconnecting
the URL from the actual location of the system on the server, because
they're easier to deal with than root-relative URLs are when moving a
site around, and pure-relative URLs just don't work when the URL is
divorced from the underlying filesystem. Unless you like screwing
around with tons of .htaccess rules.
-Otto
More information about the wp-hackers
mailing list