Using the index.html still as basic website even with something after the slash

Hi, I want to create different id´s for the website and put them behind the slash eg: example.glitch.me/this-is-the-id . If I put something behind the slash, it tells me the page cannot be found (which is obvious) but is there a way to still run the index.html with anything behind the slash?

1 Like

There’s probably a few ways to do this, but the first thing that comes to mind for me (if you’re not opposed to a bit of JavaScript) is using a Node package like Express or Fastify that allows for routing. The Glitch “Hello Node” starter project has a good example of this — basically you can write functions that define a bunch of IDs like your “/this-is-the-id” example, or even wildcards (I like Fastify’s documentation about this), and tell the page to return various outputs using a templating engine like Handlebars or Pug. That way you can have one index file, but it achieves lots of different outcomes based on what the viewer’s entered in the URL.

This project is a little old now, but may help provide an example of all that, if it helps to poke around existing code: http://oregano-blog.glitch.me/

2 Likes

allegedly glitch will serve your site that way if it’s a generated static site. back when it was a requested feature:

there are even complaints about this behavior:

edit: seems like Glitch redirects from the path to / rather than serving index.html at the path, which is the worst of both worlds. so disregard this :see_no_evil:

1 Like

Yes, node.js with express and a wildcard would probabily be the best solution