XAMPP localhost not finding external link reference files

Bagheera

Member
Joined
Sep 2, 2024
Messages
91
Reaction score
22
Credits
870
Opening my html document directly on the browser without using XAMPP, the page displays correctly with the stylesheets, graphics and Javascript linked to externally in the html header link refs.

But open the page using XAMPP and localhost, none of the external directory links work? Stylesheets not applied, images not found etc. (unformatted HTML displays though)

My basic directory structure is :-

siteA
... /HTML (containing the index.html)
... /CSS
... /Graphics
... /Javascript
... /cgi-bin

(the dots above merely to emphasise the directories are within siteA)

NOTE: My main websites folder is under /home/<my user id>/Documents/WebSites/ so is completely external to the normal HTDOCS directory.

My stylesheet link reference within the header section is thus :-
<link rel="stylesheet" href="../CSS/clock.css" type="text/css" />
<link rel="stylesheet" href="../CSS/main.css" type="text/css" />
I've tried coding "CSS/-->" and "/CSS/-->" and "../../CSS/-->" but to no avail.

HTML link to images are coded <img src="../Graphics/image_1.png">

Any ideas? I'm hoping I don't have to change too much, else it means a great deal of changes when uploading a site to a bona-fide web-server.
 
Last edited:


Some additional information ...

I displayed the website using localhost, then inspected the logs specific to this site (access logs ... the error log for site is empty)

127.0.0.1 - - [28/Jan/2025:19:06:23 +0000] "GET / HTTP/1.1" 304 -
127.0.0.1 - - [28/Jan/2025:19:06:23 +0000] "GET /CSS/clock.css HTTP/1.1" 404 1199
127.0.0.1 - - [28/Jan/2025:19:06:23 +0000] "GET /Javascript/clock.js HTTP/1.1" 404 1199
127.0.0.1 - - [28/Jan/2025:19:06:23 +0000] "GET /CSS/main.css HTTP/1.1" 404 1199
127.0.0.1 - - [28/Jan/2025:19:06:23 +0000] "GET /Graphics/logo3_component_1.png HTTP/1.1" 404 1199
127.0.0.1 - - [28/Jan/2025:19:06:23 +0000] "GET /Graphics/XAMPP.png HTTP/1.1" 404 1199

For those directories/files it lists 404 which I'm confident is not found thereby explaining why page is unformatted and without images. (I don't know what the 1199 means)
But I'm a tad surprised as to why it lists for example ...
GET /CSS .........
and not GET ../CSS .... (as defined in the HTML header link reference) ?
<link rel="stylesheet" href="../CSS/main.css" type="text/css" />

Another strange thing to me is the IP address. In etc/hosts (as directed by the XAMPP setup guide),
I defined this website as 127.0.2.1 NOT, 127.0.0.1 used by a default page. I figured each site requiring a different IP address.
 
Last edited:

Similar threads

B
Replies
1
Views
7K
Brandon Doyle
B


Follow Linux.org

Staff online

Members online


Top