How could i get a folder as a variable?

Hi all

Im struggling to figure out the right way to go about this so any tips are appreciated.
I wanted to create a birthday message site like “”
How could i get the “joe” part of it into the html? So i can have a /mary /lisa or whatever.


@bronze In the most basic sense, that could be achieved with files in the following structures:




Hi Nathan thx for answering but i think i didnt explain it clearly.
I want an html with the text saying “happy birthday joe” and, ideally, it would get the name from the url and change the displayed text. So, on the /nathan url you would see “happy birthday nathan”.

Is there a simple way to do this?

@bronze There are lots of ways to achieve this, but I’ve just noticed that you have the redirects tag set on this thread, so you may be specifically asking about redirects?

If so, I suspect what you want would be something like:

/:name  /index.html?name=:name  200

thanks a lot nathan.
i did tag it with redirect because i thought it would be relevant since i want a “catch-all” method

i cant seem to be able to get the variable from the redirected url, but i can retrieve the location.pathname

const name = window.location.pathname.split("/");
document.getElementById("name").innerHTML = name[2];