Issue with Relative Links
- Started
- Last post
- 8 Responses
- ChickenCrab
I have a couple sites set up with relative links all going from the root directory on shared hosting. (meaning <a href="/index.cfm">) Despite this being very wrong (which I just found out), the sites have all worked perfectly fine for months — up until yesterday when one of them started trying to pull includes from other sites on the same server. The others all still work fine and are hosted by the same company.
All of the includes are ColdFusion based, which means they can't simply be changed to be absolute from the domain because ColdFusion doesn't allow that easily (mappings I don't know how to do). The obvious solution seems to be to go in and recode all the links to be relative to each individual page rather than the site root.
Would you agree, or is there something easier I just don't know about?
- blaw0
Since a global find/replace won't work, you could use Dreamweaver's "Change Link Sitewide", which would automatically update the links with the proper path, regardless of their nested depth. This still means you have to hit every link, just not every instance of every link.
- grunttt0
but... that's not... easy.
- ChickenCrab0
Thanks for the response. I figured out that I have a bigger problem though since none of my included files will work correctly when they're no longer relative to the site root. I need to do some more thinking.
- acescence0
so why did everything suddenly change exactly? i don't see how links relative to web root and parsed by a web browser would affect includes. include paths are typically relative to your home directory, which is not the same path as what's publicly browsable on the web side.
- I have absolutely no idea. We haven't changed the files though, so whatever happened was on the hosting side.
ChickenCrab
- I have absolutely no idea. We haven't changed the files though, so whatever happened was on the hosting side.
- ChickenCrab0
I'm trying to figure out ColdFusion mappings right now so I can get the absolute links to work correctly.
- ChickenCrab0
After a couple years at this, I'm still a bit of a rookie trying to figure out web design as I go. Is there any real reason why links relative to the root would not work with includes on a shared server? I always assumed they were just calling to the root of your part of the server, not the entire server.
- acescence0
when people connect to a web server through http, all of the paths they see are relative to http root. when code executes on your server to serve your site, all of those paths are typically relative to your home directory, which is above http root.
- ChickenCrab0
Interesting. I think I need to push the host for some more answers.