Jump to content

Recommended Posts

Posted (edited)

Ran into another snag. My relative links in my includes are not resolving correctly. Live on my hosts server simply begining the url with "/" works perfect (eg /img/test.jpg). But not so in Wamp. I havn't tested this yet but I imagine if I were to use an absolute path or possibly my local directories full path (aka my computers path) it would work correctly. This is obviously not the optimal solution. I need to resolve this or I'm back at square one again. I did quite a bit of googling but couldnt find the solution. Have any of you ran into this or can you find the fix? Thanks!

 

This might possibly be due to the fact that I'm pointing wamp at my website files and they are not sitting in the wamp/www. directory. Possibly?

Edited by Eric
Posted (edited)

Ran into another snag. My relative links in my includes are not resolving correctly. Live on my hosts server simply begining the url with "/" works perfect (eg /img/test.jpg). But not so in Wamp.

 

This might possibly be due to the fact that I'm pointing wamp at my website files and they are not sitting in the wamp/www. directory. Possibly?

 

Relative links do work in Wamp or from any other local directory PROVIDED that they aren't root-relative links like you have. If a link is a normal relative link like image.jpg or images/image1.jpg then it works locally but if you start with a / like /image.jpg or /images/image1,jpg the browser goes to the root directory and works from there, which is probably C:\ on your computer with lots of subdirectories before you reach the www directory so the file isn't found. On your host's server the root directory is the first you use.

 

So if you use root-relative links, always test online.

 

Edit: I've never set up a virtual host to use Wamp (but I normally use normal relative links, not root-relative links).

Edited by Wickham
Posted

Relative links do work in Wamp or from any other local directory PROVIDED that they aren't root-relative links like you have. If a link is a normal relative link like image.jpg or images/image1.jpg then it works locally but if you start with a / like /image.jpg or /images/image1,jpg the browser goes to the root directory and works from there, which is probably C:\ on your computer with lots of subdirectories before you reach the www directory so the file isn't found. On your host's server the root directory is the first you use.

 

So if you use root-relative links, always test online.

 

Edit: I've never set up a virtual host to use Wamp (but I normally use normal relative links, not root-relative links).

 

Your right! I worded it wrong. When testing in Wamp and having it setup as an Alias relative links in my includes only worked at the root level. As soon as I needed that same include to display the code in a file outside the root it no longer worked. So I needed to use an absolute path (/). Absolute path only works with the Virtual Host setup. In the end almost just as easy. Just took a bit more time to figure out.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...