I've encountered a file path issue with my HTML and CSS files. My HTML file is located in:
src/test/html/index.html
And the corresponding CSS file is in:
src/test/css/index.css
In the HTML file, the CSS is linked using:
<link rel="stylesheet" type="text/css" href="../css/index.css">
Everything works smoothly when I run http-server
from the project's root directory and access the page at:
http://127.0.0.1:8080/target/test/html/
However, if I serve the contents of the HTML directory so that the index.html
appears at the root like this:
http://127.0.0.1:8080
The CSS fails to load. This seems to be due to the browser not recognizing the navigation attempt (essentially trying to go beyond the root path /).
Is there a workaround for this issue without having to rearrange files, ensuring that the CSS can still be accessed via this URL:
http://127.0.0.1:8080