Welcome to the Treehouse Community
Looking to learn something new?
Guillermo Gomez7,413 Points
Workspace is retrieving the index.html if the file doesn't exist
When I'm on the Workspace, whenever I type in an unexistent URL, in the main path or in a subfolder, the server retrieve the index.html instead a 404 error. The following is the code from the AJAX Basics Course:
Dave McFarlandTreehouse Teacher
Thanks for pointing this out. You're right, you literally can't get a 404 error in the workspace right at this moment -- it loads the index.html file if you request a file that doesn't exisit. This is NOT a common behavior -- most web servers DO NOT act this way: they return a 404 if you request a resource that doesn't exist. I believe we are going to change the workspace behavior BACK to returning a 404 error, since that more accurately reflects how it works in the real world.
In regards to your question (or statement?), it's probably so that the user can call their base html file anything they want and it will still act like the index page. Otherwise there would need to be some sort of routing rules put in place for each specific Workspace to match the files the user creates.
Treehouse could either:
- Force users to use index.html (making things confusing across different stages in the same course)
- Add an option in the Workspaces to mark a page as the 'home' or 'index' page (adding complexity to the structure of each workspace)
- Leave it as is
Personally, I don't see it as being a big issue, since most users will prefer to see something familiar than a big scary error message or a generic 404 page.