1

I don't think the title is that clear, so I apologize.

Long story short, I wanted to make a website using http-server and ngrok. I created a 404 page to handle page not found errors. It worked, if the link is like localhost:8080/abc; it didn't work (CSS styling doesn't apply, button doesn't work) if the link is like localhost:8080/a/b/c/.

My directory is:

fonts    //
images   // Not important
pages    //
scripts
    404.js // This file has a function with 'window.location.href = "index.html";'
    style.css // This is not important
index.html
404.html // This file has a button which is controlled by scripts/404.js

I want to make the 404 page work for whatever invalid URL the user put (example at the top), how can I do that?

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
  • 2
    It's likely that you're using relative file paths in the 404.html file. Consider using absolute URLs? – evolutionxbox Jul 22 '22 at 12:00
  • I guess it was too hard to add ngrok in the title and in tags to make it clear :D the edit queue is still waiting for the previous proposal – Diego D Jul 22 '22 at 12:04
  • Ngrok is just a proxy. You’ll need a full web server – Daniel A. White Jul 22 '22 at 12:07
  • @DiegoDeVita Sorry, I forgot to say that the ngrok isn't active yet since the website is not ready – FighterLoveNoob Jul 22 '22 at 12:09
  • the point is that there's no javascript in your issue.. or better.. saying javascript is like saying your problems is also related to the english language because you are using words. I have no knowledge of ngrok but here the issue is how to craft a rule to override the response for 404 and I have no idea how otherwise you had my answer already. The user evolutionxbox gave a suggestion but you didn't say anything about it – Diego D Jul 22 '22 at 12:12
  • And if you say that ngrok is not even active yet, and if as said in the comments, ngrok is just a proxy server, the problem relies on your actual http server... you should say more about it. Lots of confusion here – Diego D Jul 22 '22 at 12:15
  • @evolutionxbox I just tried it, and now it's giving me the "Not allowed to load local resources" error. – FighterLoveNoob Jul 22 '22 at 12:18
  • @FighterLoveNoob https://stackoverflow.com/questions/37690419/not-allowed-to-load-local-resources – evolutionxbox Jul 22 '22 at 12:20
  • @DiegoDeVita Sorry again, I forgot to remove the ngrok tag from the question – FighterLoveNoob Jul 22 '22 at 12:20

0 Answers0