Page 1 of 1

Images not working with root relative link

PostPosted: 04. March 2012 21:00
by joshualemli
I recently installed XAMPP in order to test my PHP pages without uploading them. Localhost is up and running, all fine there.

The issue is that whenever I have an IMG tag, my image only displays with an absolute or relative SRC. However, I almost always use a leading "/" (src="/blah") so pages can be moved within the site and the images will remain intact. So essentially,

This WORKS:
Code: Select all
<img alt="whatever" src="../imagefolder/mypic.jpg" />

or
Code: Select all
<img alt="whatever" src="http://www.myurl.com/imagefolder/mypic.jpg" />


This DOES NOT WORK:
Code: Select all
<img alt="whatever" src="/imagefolder/mypig.jpg" />


I believe this is because my leading "/" is telling XAMPP to look in the htdocs folder, possibly? Is there something in the apache httpd.conf file I can edit to fix this issue? All images display fine if I open the local file with a browser (obviously, though, my PHP doesn't get parsed!). Images are fine when the site is online. Any ideas?

- joshua

Re: Images not working with root relative link

PostPosted: 19. March 2012 18:57
by anselm
Hi joshualemli,
only this works...
<img src="verzeichnis/datei.gif" alt="Grafik">
<img src="verzeichnis/unterverz/datei.gif" alt="Grafik">
<img src="../datei.gif" alt="Grafik">
<img src="../../../datei.gif" alt="Grafik">
<img src="../woanders/datei.gif" alt="Grafik">
http://de.selfhtml.org/navigation/suche/index.htm?Suchanfrage=img
Best Regards