How to return a 404 page for a given route?
-
I'm using Categories as my home page route so have no need for the example.com/categories page. I thought hey, why not have Nginx return a 404 page when users try to visit
/categories
:location /categories { return 404; }
But my bright idea isn't quite working because I get the standard ugly Nginx 404 template:
Does anyone know how I can get the Nodebb 404 template to show instead? For example:
-
There should be A way to make that appear by the nginx config, googling "nginx custom 404 error" might help
-
@henrywright I'll see if I can somewhat fake it with bootstrap & css
-
You may try redirecting to the
/404
route. It might not look like exactly what you want:location /categories { return 301 $scheme://your.site/404; }
It will give you something like this
If you want it to say /categories not found, you could try redirecting to
/categoríes
(replacingi
withí
, i-acute) -
@henrywright I think you'd have to do so within NodeBB itself. Also, I don't suggest disabling any routes NodeBB may use, as they are hardcoded and 404ing them could mess stuff up.