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

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

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

Postby davidnoble » 26. December 2010 08:35

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
davidnoble
 
Posts: 2
Joined: 26. December 2010 08:15

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

Postby Sharley » 26. December 2010 09:48

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.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

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

Postby davidnoble » 27. December 2010 00:07

That does make sense. Thanks for your help!
davidnoble
 
Posts: 2
Joined: 26. December 2010 08:15


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 29 guests