Jump to content

Relative Paths Not Quite Working


JustinK101

Recommended Posts

Hello, I have an application I coded and tested on a windows 2003 server running iis and php5. Recently I took the application and copied it over to a Linux CentOS 4.4 install running Apache 2 and PHP5. I was a little annoyed to find many of my links and image paths do not work.

In windows (IIS) I did the following often:

< img src="/images/myimage.jpg" >  I did this because I need to go home / and then following the directory structure that way, instead of doing < img src="../../../images/myimage.jpg" > because often times the path is a variable I don't know how deep I need to backtrack to get to the root/home directly. So, doing the / worked and took me home in IIS. This works because the application was on its own virtual web-site so it knows that / means go to its particular home.

With apache it is different because I don't have a  virtual web site defined, so / takes me back to the public_html directly and not the public_html/myApplication/ directory.

All in all, I know I can make a virtual directory for my application in apache and it should work, but what is the solution so when I make my application available for download that anybody can just stick it in a folder and not have to create a virtual web site and worry about this? I fear it requires me to always use ../ to descend into the proper directory correct?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.