0

I want to change the default 404 page of the python3 module http.server to a custom 404.html page, so it will redirect the client to that page.

I have confirmed the 404.html works, but putting a 404.html in the web root doesn't help.

Any solution?

6
  • 1
    First of all http.server module is not intended for production. It is not designed to be that at all. Placing a file called 404.html in web root does not mean it will be taken as 404 page from web server at all. You need to specify the webserver what to do in case of 404 event. Commented May 8, 2022 at 7:19
  • @Bijay Regmi thx for your answer. then what should i do? i usually start the server with this command, python3 -m http.server cuz i am on Linux. Commented May 8, 2022 at 8:00
  • 1
    Use Nginx if you already have your html files. If you are on debian based systems sudo apt install nginx and put your html files in /var/www/html. Everything about this is customizable so all you need is do a small bit of research. Commented May 8, 2022 at 8:13
  • 1
    stackoverflow.com/questions/1024199/nginx-customizing-404-page Commented May 8, 2022 at 8:14
  • 1
    In conclusion, is that IMPOSSIBLE with python http.server? Anyway, I am on Xubuntu. Let me figure out how nginx works Commented May 8, 2022 at 9:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.