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
https://forums.phpfreaks.com/topic/33570-relative-paths-not-quite-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.