root
|- subdir1
|- subdir2
|- index.html (refers to style.css with path "style.css")
|- style.css
When I start a server with root as its directory and visit it in the browser, the links to the subdirectories are like <a href="http://localhost:8090/subdir2">subdir2/</a>. (Note: there's an ending slash in the text but not in the link.)
When I go to http://localhost:8090/subdir2, I actually visit subdir2/index.html, but due to there being no ending slash in the URL, the browser thinks the ULR of the CSS file would be http://localhost:8090/style.css.
To fix this relative path error, we should append a slash to its link if an item in the list is a directory.
And another flaw, the slash(/) is encoded as %2F in the link, though it is right, it's kind of abnormal and ugly -- I think we'd better keep slashes as slashes in URLs.
I have a directory:
When I start a server with
root
as its directory and visit it in the browser, the links to the subdirectories are like<a href="http://localhost:8090/subdir2">subdir2/</a>
. (Note: there's an ending slash in the text but not in the link.)When I go to
http://localhost:8090/subdir2
, I actually visitsubdir2/index.html
, but due to there being no ending slash in the URL, the browser thinks the ULR of the CSS file would behttp://localhost:8090/style.css
.To fix this relative path error, we should append a slash to its link if an item in the list is a directory.