Strip part of URL in Pages

We currently use Apache as a backend to serve up static content that is cached by Cloudflare. We are looking at just removing the Apache backend and serving it all through Pages. The only issue I have is that we do something weird where we have a customer name in the URL that we ignore. For instance goes through the below rule which basically strips out the Customer1 bit and looks for /var/www/html/app/app1/index.html

AliasMatch ^/[^/]*/(.*) /var/www/html/app/$1

Can i replicate this using pages ?

Yes, you could replicate this using Pages.

The simplest way would probably be to use a function that runs on /:customer/:app/ and then serves the necessary HTML file.

Pseudo-code example:

// functions/[customer]/[app].js
export function onRequestGet({params, next}){
    const html = await next(`${}`); // fetch app page without customer prefix
    return html;

For more information about Functions, check out the docs below:

1 Like