Support » Fixing WordPress » Noob, relative paths, images, and subdomains

  • Newbie seeks advice. I only have a minimum of WP jargon so far, which may be the problem.

    My first test blog has a couple of postings. The blog is located at

    The postings have some embedded images, using relative paths, a la:
    <img src=”/blog/wp-content/uploads/2006/05/MyPix.png” etc >

    This worked just fine. Now comes the trouble. I created a subdomain on this server with good ol’ cpanel: <>. This resolves to <;

    Now the ‘front’ page created by WP has an extra, unecessary ‘blog/’ in the path. The individual posting pages are fine. I can remove the ‘blog/’ part of the tags and reverse the results. My question is then, do people use absolute paths (that seems odd), or is there another level of manipulation that must be performed in order to use a subdomain? I also realize that going into the individual postings results in the default URL of (for example) <;, which I need to deal with anyway.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator Samuel Wood (Otto)

    (@otto42) Admin

    If you want it to work with both URL structures, then yes, you’ll have to use absolute links. This is not specifically a wordpress problem, it has to do with the way the URL is resolved.

    You’re specifying the relative links as /blog/blah/blah.. When the browser gets this, it resolves it to

    But when you changed the domain to, and have apache shift that by adding the /blog folder to it internally, then yes, now your links are wrong.

    Can’t have it both ways.

    Well, you *could* have it both ways with some rewriting. Basically you’d check to see if the url contains “” and eliminate the offending “/blog” from the URL if so. You could do this in .htaccess or httpd.conf.

    Thanks for responding. So, am I correct in assuming that absolute links is the way to go, that is, it’s what people normally do? It makes sense of course, but I wonder what happens when people try to move their entire blog? Is my method of inserting <img> tags right into the posting considered odd?

    I think I get the reference to the bit about removing the offending part of the path. This is similar to the snippets I’ve seen about protecting images and such. I add the bits into .htaccess to manipulate the URL as I see fit, including eliminating requests for images that don’t come from my own domain. Is that about right?

    I just (in the last few mins) added the bits to use the name & slug in my URLs, which is a step in that direction. I can’t recall any examples at the moment, but my intent is to have my URLs (in addition to being maintainable) look something like:


    Would this be considered a horrifying faux pas or something? I freely admit to being a noob and ignorant of most netiquette. Thx, Mike

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    The more usual approach is to use only one url or the other. Trying to use both and is the problem here.

    If you are trying to permanently move your blog to the new domain name, and don’t care about the old URL working anymore, then the easiest way to deal with it is simply to edit all your old posts to remove the /blog thing. This is easier than it sounds if you have control of the database. Use the database backup plugin to generate SQL dumps of the database, open them in a text editor, search+replace, run the SQL to rebuild the database.

    Alternatively, use URL rewriting to remove the “/blog” on the new domain. This handles your old posts okay, and then for new posts you can simply not put it there.

    Very generally speaking, people don’t move blogs around. It’s one thing to change hosting, it’s another to change the existing URL structure of an already established blog. Changing hosts is easy. Changing URL structure is fraught with perils, as you now see. 🙂

    Also, if you have very few posts on this blog, then you can probably just go edit the old posts quicker than screwing around with rewrites and such. But then if you have 10k posts, that’s probably not a good option. 😉

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Oh, and very generally speaking, you want to use absolute URLs for everything. Why? RSS feeds. RSS Readers may not be able to display your images correctly if you use relative links.

    But that’s a matter of debate, really.

    I don’t know about your cPanel, Mike, but in mine when setting up a subdomain I can choose whether to redirect to a folder or not.
    When it is a redirect – nothing will work properly, I call them the fake subdomains.
    If not redirected, then WP understands the URIs in the Options.
    (This is based on own personal experience AND the countless posts here complaining about the same as you did)

    Okay let me absorb…

    Absolute URLs to images – check
    Don’t sweat absolute URLs or fixing existing posts – check
    I want to use my subdomain, and not redirect – I think?
    And the Options will allow WP to use the subdomain (sans redirection) automatically- I think?

    I need to try this tonite and see.
    Thanks guys

    Hmm. I’ve canceled redirection. Assuming I’m not suffering from a subdomain issue…

    I’ve set my Options up like so:
    WP address:
    Blog address:
    for my blog which currently resides at the address

    Entering the URL sucessfully loads the ‘main’ page, the same as it did when I had redirection to That was easy.

    However, the clicking on the posts will now attempt to load a page at<datestuff>/<slug> (I have edited the blog root’s .htaccess for this form)

    This always fails with a 500 error. I’ve just realized that my blog is not at the root level, but in a folder within root; the account is set up by the provider as
    Since I’ve never used the /public-html/ path segment anywhere in setting up anything, does that mean the provider has some kind of redirection set up on his end (httpd, et al)?? I’m starting to get confused…

    WP address:
    Blog address:

    What I was trying to say: if you have a “normal” subdomain (not redirected anywhere!!!) then the two URIs should be the same.
    Whether the subdomain is real or not should be set on your site’s level, not in the WP’s admin.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Noob, relative paths, images, and subdomains’ is closed to new replies.