Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    My problem is that on the /glacier install all relative links point to the root install.

    You mean a link like <a href="/foo/">Foo!</a> comes out as http://www.swanmountainoutfitters.com/foo/ ? Or something else…

    Where are these ‘relative’ links? In a theme or what? How are they set?

    Thread Starter ViPeRx007

    (@viperx007)

    Yes, in my example above the actual HTML of that image is this:

    <img src="/wp-content/uploads/swan_mountain_outfitters_glacier_division.jpg">

    and it comes out as…

    <img src="http://www.swanmountainoutfitters.com/wp-content/uploads/swan_mountain_outfitters_glacier_division.jpg">

    …instead of how I’d like it to be, which is…

    <img src="http://www.swanmountainoutfitters.com/glacier/wp-content/uploads/swan_mountain_outfitters_glacier_division.jpg">

    The links are actually within the content. They were set as relative because I knew I’d be moving the site from a preview to the subdirectory. I have no problems when I’m doing a normal root install, but the subdirectory is throwing me off.

    On the /glacier homepage, all of the links in the center column (text links, images) are all incorrect. I could go through and update them all manually and give them absolute links, but it seems like there should be a way to just make the relative link use http://www.swanmountainoutfitters.com/glacier as the root instead of it going all the way back to http://www.swanmountainoutfitters.com.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    So you MANUALLY made these links?

    The short answer is this: Nothing is wrong, every thing is working 100% as they’re supposed to. You made the links root relative. In every single webpage, be it WP or raw HTML, that means “Relative to root” not “relative to me”

    Relative to me would be this: <img src="wp-content/uploads/swan_mountain_outfitters_glacier_division.jpg">

    And that won’t work since you’d get this:

    <img src="http://www.swanmountainoutfitters.com/glacier/postname/wp-content/uploads/swan_mountain_outfitters_glacier_division.jpg">

    So … tl;dr? Add in /glacier or stop using relative links.

    Thread Starter ViPeRx007

    (@viperx007)

    Can I change the root of the /glacier install to /glacier then or is it impossible to stop it from going all the way up to the top level? I realize that technically it’s working how it’s intended to work, but it’s not working for my purpose and so I’m forced to modify it if possible. I just don’t know how to.

    I’d like to avoid having to go through and change all of the links manually if possible, but if that’s what has to be done I will.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Can I change the root of the /glacier install to /glacier then or is it impossible to stop it from going all the way up to the top level?

    You could probably write in a code filter, but it would have to scan the content of every post, and that can be expensive on your CPU and memory usage.

    The best fix is to stop using / and start using /glacier/ – go back an edit all the old posts (or do a search/replace on the posts and change it).

    Thread Starter ViPeRx007

    (@viperx007)

    I ended up just going through the content and changing all the links manually. I’ll chalk this one up to a learning experience regarding links if I ever have to do another subdirectory install.

    Thanks for the help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Problem with relative links on subdirectory install’ is closed to new replies.