Im wondering how to make a custom 404 page, I’ve searched online and found you need a file called .htaccess
and type ErrorDocument 404 (location of error 404 document)/error404.html And it doesnt work. Any help is appreciated.
You can’t use a .htaccess file on Glitch. One way to do it is to use Express and set the last route to be one that catches everything that hasn’t already been handled by a route. So in https://glitch.com/edit/#!/simplistic-farmer for example, I have a route for ‘/’, the homepage, which renders: https://simplistic-farmer.glitch.me/ but if I try going to https://simplistic-farmer.glitch.me/gfdgdfgfdg it shows 404, because of the app.get('*'
on line 19: https://glitch.com/edit/#!/simplistic-farmer?path=server.js:19:1
Thank you! But what about making a complete separate page for it though like they will be redirected from https://simplistic-farmer.glitch.me/gfdgdfgfdg to https://simplistic-farmer.glitch.me/404.html or showing that HTML page.
I’ve updated the example to use a page, see https://glitch.com/edit/#!/simplistic-farmer?path=server.js:18:0
Thank you so much! Helped alot!
I’m very sorry to revive the conversation but I try to make this solution and It don’t work…
Can you help me ?
Im trying to make it in ejs and i but that code from server.js in my app.js but it just send a error here
and im trying to fix but it just get more error then
Thats your issue
Let me say in advance that I am very sorry to bump this thread, but it looks like you are using the PHP development server. You should switch over to lamp-poc and create a .htaccess file with the following:
ErrorDocument 404 /your404page.php
No worries about bumping the thread - I didn’t know app.get("*", ...
was a thing until today. Gotta try it!