NodeJs / ExpressJs URLs

I need to parse parameters in the URL that come in this form:

localhost:8080/p/a=12345&b=acbd

After the variables are read, I load a HTML file that is in the public folder of my express server. That works ok. The problem is that my HTML file load several JS and CSS files and since the path is localhost:8080/p/ the files with relative paths can't be found.

What I need is something similar to the apache URL rewrite, where I can send the traffic to a specific file and change the URL to look in the way I want. I haven't found a node module that does that, any suggestions?

If you are using the static middleware to serve your static files, you can use

app.use('/p', express.static(__dirname + '/public'));

instead of

app.use(express.static(__dirname + '/public'));

You can see more details in the document of the Express