• How do I tell WP to generate relative urls for links to images and other media, and links to other posts/pages?

    When these links are generated completely dynbamically (like via the bloginfo() function) it is ok-ish, but when fully-qualified url’s find their way in posts/pages it becomes a royal pain in the butt to move the site from the development/staging url to a live url.

    Basically I’d have to search/replace the *entire* database to be fully sure that everything has been deployed good and well.

    Not that this happens oftenly for a single site, but it does happen for every site that I have to build. After all, we can’t put an empty site onto the live environment.

    So how do I go about this? Relative url’s don’t hurt, or I don’t see how they could.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Relative url’s don’t hurt

    They do in WordPress.

    Thread Starter thanatica2

    (@thanatica2)

    Really, why? Does wordpress really, absolutely, indisputably need to include the full http-part and domain part? Why why why? Not a single non-wordpress site I’ve ever built (quite a few) needed them to link to within the same site.

    I’d love to be convinced otherwise, but a simple “wordpress need them”, or something like that, is no reason ??

    It’s the way in which WordPress core currently works. I’m sorry but that’s all there is to it – although I’m sure you might find some more detailed explanations in the archives of the wp-hackers list.

    Relative urls simply don’t work predictably.

    Thread Starter thanatica2

    (@thanatica2)

    So if my site is https://example.com/ I could just strip off “https://example.com” from each and every link to make them work (as in: make them deployable to a new domain). That will make them relative [to the root of the website], and is 100% predictable, even when the wordpress core somehow doesn’t know which url it is at.

    Weird. I wonder if I could put together a plugin that fixes this ??

    How would you handle a custom permalink structure change without breaking any links?

    Thread Starter thanatica2

    (@thanatica2)

    If a custom permalink is something like:
    /year/month/day/title
    Then it becomes
    /2011/01/21/Try-this
    As a relative url.

    This will work fine, because when a visitor goes to a permalink, the browser will recognize that the domain has to be the same as in the address bar. When using it for bookmarking, the browser will, again, recognize that it needs to prepend the protocol and domain to make it fully-qualified.

    Only when using permalinks for pingbacks and such, you’re probably better of with absolute urls, but those are special and are probably generated on the fly.

    My point was meant to be – how will the plugin cope when a permalink structure that was /year/month/day/title changes to /year/month/title?

    Thread Starter thanatica2

    (@thanatica2)

    Well, it would only strip off the domain. The rest is left alone… It would probably keep working, right?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Relative urls please?’ is closed to new replies.