Page 1 of 1

Site relative links point to localhost, not my site folder?

PostPosted: 26. December 2010 08:35
by davidnoble
Hi,
I'm new to XAMPP and I can't tell you how much I would appreciate an answer to this problem I'm having with relative links linking to my localhost folder instead of my site folder (within the localhost). When I code a relative link (e.g., "/pages/audio1.mp3") the only way I can get it to link correctly is to include the site root folder name (e.g., "/mySite/pages/audio1.mp3"). At first I assumed it must have something to with my settings in Dreamweaver, but after a great deal of reading and fooling around with the settings, I suspect it's a mistake or poor assumption I've made with my XAMPP settings. Here are my site settings in Dreamweaver:

Local root folder: C:\xampp\htdocs\mySite\
HTTP address: http://localhost/mySite/
Testing server folder: C:\xampp\htdocs\mySite\

Thanks so much to anyone who can shed some light.

David

Re: Site relative links point to localhost, not my site fold

PostPosted: 26. December 2010 09:48
by Sharley
davidnoble wrote:When I code a relative link (e.g., "/pages/audio1.mp3") the only way I can get it to link correctly is to include the site root folder name (e.g., "/mySite/pages/audio1.mp3").
The slash at the beginning of your path is telling Apache to look in the server's DocumentRoot - htdocs - then it looks for the folder pages in the htdocs folder and then in the pages folder for the audio1.mp3 file - this will give a server error.

So by simply dropping the leading slash so it looks like this - pages/audio1.mp3 - Apache will look in the pages folder of the mysite folder for the file audio1.mp3 and not give an error because it can find the mp3 file.

Your relative path should look like this:
Code: Select all
"pages/audio1.mp3"
If you add a leading slash then Apache will try and find:
C:\xampp\htdocs\pages\audio1.mp3 which it obviously can't find and will give a 404 file not found in your apache\logs\error.log file - always look in the error.log file for clues when ever you get a server error.

Re: Site relative links point to localhost, not my site fold

PostPosted: 27. December 2010 00:07
by davidnoble
That does make sense. Thanks for your help!