While debugging my site, I have noticed a weird thing happening. Lets say the html file has a hyperlink like so:
<a href="../">This hyperlink uses "../" to take you back one directory</a>
If I debug my own site in vscode and use chrome, if I click this, it gives me a weird page that says "Index of /Users/myusername/code/public_html/aboutme/" and shows all of the files in that directory. But then when I upload the files to my host, everything works just fine. Why is this? I suspect it may have to do with the way that "index.html" works.
CodePudding user response:
A typical configuration for an HTTP server which is serving static files (i.e. mapping URLs directly onto files on the filesystem) is that if the URL maps onto a directory then to look for a file named index.html (or similar) and response with that.
For example, when using Apache HTTPD, this is handled by the DirectoryIndex
directive.
When dealing with a file:///
scheme URL then there is no HTTP server which can do that mapping and the code internal to browsers which handles file:///
scheme URLs doesn't do it either.
CodePudding user response:
It will be because your server has a .htaccess
file (in most cases) which looks for and displays an index.html
file when it can find one. Your local file system won't have that so will just display the directory.
EDIT: the .htaccess
file basically ensures the site user isn't presented with some confusing page where they have to select a page to view.