When user enter the wrong url, the node js server will redirect to 404.html page, how can I implement this on nodejs. Do some search and it points me to expressjs ( looks like a nodejs wrapper ) but I want to write in nodejs.
Thanks for reading .
When user enter the wrong url, the node js server will redirect to 404.html page, how can I implement this on nodejs. Do some search and it points me to expressjs ( looks like a nodejs wrapper ) but I want to write in nodejs.
Thanks for reading .
The logic of determining a "wrong" url is specific to your application. It could be a simple file not found error or something else if you are doing a RESTful app. Once you've figured that out, sending a redirect is as simple as:
response.writeHead(302, {
'Location': 'your/404/path.html'
//add other headers here...
});
response.end();