Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

directory question

Status
Not open for further replies.

kpdvx

Programmer
Dec 1, 2001
87
US
This may be more of an HTML question, but here goes.

I've been building PHP websites for a while, and I've always built my user interface in a file called ui.php, and I include ui.php from my pages. This works fine, unless I include it from a directory within my root directory, like for example, /admin. The images and css calls are all off because it is trying to look for them in its current directory.

Is there any way I can set the image and css links to go to the root directory and go from there, so that my images will display from no matter what directory I include ui.php from?

Thanks!
 
More of an HTML question ... but it is a common problem with all scripting because of the including scripts from other directories.


Here is how I have resolved the problem.
Use absolute urls instead of relative urls:

picture example:
<img src=&quot;OR
<img src=&quot;/images/picture.gif&quot;> (notice the leading '/' at the start of the source)

instead of
<img src=&quot;../images/picture.gif&quot;>
OR
<img src=&quot;images/picture.gif&quot;> (no leading '/')

hope this helps :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top