Forums

Removing the .html extension in the address bar

Hello,

I am currently setting up a flask app where all the html files are static, so at the moment I have changed the settings for my web app to serve static files from the 'empty' URL from a specific directory. For example, that directory has index.html in it, which is loaded when you go to mysite.com.

This seems to work fine but I have another page: mysite.com/other-page. The html file is saved as other-page.html. If you visit mysite.com/other-page.html it will load, however there is an error upon visiting mysite.com/other-page (without the .html extension). Now I could use flask to solve this by serving the correct html page when /other-page is requested, however I've read it's best to do that at the web server level. Does anyone know how that would be done? I apologize if this is a dumb question, I'm quite new to web development.

Thank you!

Instead of having your html in page.html , put it in a directory called page and name the file index.html. Then change the links that go to that page to /page/

That should do the trick, thanks!