Starting links with / in a Windows...

User 2165005 Photo


Guest
1 post

Hi,
Bit of a noob html question here.
I want to start some img links in my menus with "/" so that it will start looking from the root directory.
This works fine once the page is uploaded to the server but in a windows environment (my local computer) the browser will go all the way back to the root drive ( c:\ ) which isn't what I want.
It's not a big deal, just makes it harder to test the pages locally.
Is there any way around this?

Thanks,
Adam
User 38401 Photo


Senior Advisor
10,951 posts

Hiya Adam,

the best way to make sure you're online and offline pages view correctly is to keep the exact file tree for your project as you do for your remote folder. That is the only way that you can use that type of URL, which is the correct way to do it. Otherwise if you don't have the images in the same location locally as they are remotely, the URL will not look in the right places.

Another tip is if you are working on a page that is in a subdirectory and it's referring to something thats a different subdirectory such as a "gallery" folder and an "images" folder both folders in the root directory, then you need to tell the image link to go up one folder before it looks for the folder after the / so you add to dots .. in front of the slash like so:
../directory/filename

An example like above would be an images folder inside your main root folder. You created (hypothetically lol) a gallery folder and putting your gallery files in there but you want to reference a logo image or any image from the main images folder so you would put the dot dot to say back up one directory (sends the code to the root) and then the link like so:
../images/filename

That says go back up to the root and then into the images folder and find the file. :)

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.