I am actually looking for a way to get all the URLs entered so that I can redirect the wrong URLs to a 404 page.
when I hit different url s like localhost:0000/details
, because location.href
is in index.html, this code is not executed. and I can't figure out the URL to redirect the user to the desired page.
The exact answer in your case will depend on how your are serving your HTML pages, but generally, you would configure you're server to handle a
404 not found
response by sending back a specific HTML page.See this section on the MDN '404 Not Found' page regarding custom error pages. This section specifically refers to the Apache server, where you would add the following to a
.htaccess
file.Hope this helps.