WordPress.org

Ready to get started?Download WordPress

Forums

Default links to files could be done better... (3 posts)

  1. copperblade
    Member
    Posted 3 years ago #

    For a long time I've wondered why wordpress creates links to files using the full URL instead of a relative URL. Today I just moved a site and had to get into the database and do something like:

    UPDATE wp_X_posts SET post_content = replace(post_content, "http://BLOG.DOMAIN/files", "/files");

    just to get all the images working again. I know in the case of blogs as subdirectories, you'll still have to have something like /BLOG/files as the default location, but subdomains only need /files which would never change even when it gets moved.

    I guess this isn't so much of a complaint as a suggestion... unless there's a reason why relative URLs break other things.

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    Try looking at where theme template files are stored and where plugins are stored and it becomes easy to see why trying to create relative urls in every situation would be a nightmare.

  3. copperblade
    Member
    Posted 3 years ago #

    I'm not sure what you mean... themes and plugins already are relative to your install and aren't hardcoded or in the db anywhere AFAIK.

    I just mean the URLs to things that the media manager creates. It defaults to the domain path. I've done the above global replace on the database for 5+ blogs now and they all work fine with relative locations.

    When editing the site attributes I see that the Fileupload URL is set to http://BLOG.DOMAIN/files and I changed this to just /files

    I hope that does the trick.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags