Images not working with root relative link

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Images not working with root relative link

Postby joshualemli » 04. March 2012 21:00

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,

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

Code: Select all
<img alt="whatever" src="" />

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
Posts: 1
Joined: 04. March 2012 20:47
Operating System: Windows 7 64-bit

Re: Images not working with root relative link

Postby anselm » 19. March 2012 18:57

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">
Best Regards

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 72 guests