Ask coding questions

← Back to all posts default 404 page
InformaticaH4 (2)

I want to change the 404 page to my own 404 error if an unknown link is entered. I use HTML5 and CSS3.


A 404 page is possible but not with html css and js. For example: @kognise made this web with next.js. With NodeJS, NextJS, Python, and Express you can make a 404 page. Upvote this comment if it helped you

ash15khng (678)

I don't think that is possible as of now.

LuukDev (0)

What you can do is create your website with PHP Web Server. A 404 page will automaticly be your home page. So you can make your home page a 404 page and set the codes you want for that page in a .txt file. Then add in the 404 page/home page the following script:

<script> if (location.pathname == "/example"){ var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.body.innerHTML = xhttp.responseText; } };"GET", "/example.txt", true); xhttp.send();} } </script>