Hi dra,
I now understand more clearly what you want
The technical term for what you’re describing is “URL rewrite”, so you rewrite any URL that contains “.php” and remove it
The following NPM package does the job:
The challenge is adding such package as a Wappler server connect extension. You can find an example for another package here:
I learned how to do the above by looking at the below example:
And, lastly, you would need to come up with a regular expression (regex) that captures/selects all of your URL except “.php”. Unfortunately, I’m not really a good regex builder, so here’s another alternative that works by simply replacing “.php” with “” (empty string):
exports.before = function (app) {
// Remove .php from URL
app.use((req, res, next) => {
req.url = req.url.replace(/\.php$/, '');
next();
})
};
Well, actually, we’re still using regex. But I used Github Copilot to generate the regex for me And you don’t need to install the NPM package anymore
Aside from the regex, I learned to do the above partly from here:
https://pavelbucka.com/how-to-rewrite-url-in-express/