google-cloud-storagegoogle-cloud-load-balancer

Strip the .html extension from webpages


Is there a way to strip the .html extension from webpages on a website running on GCP Application Load Balancer?

Normally, this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

should do the trick.

But I can't see how something comparable can be used in the Advanced host and path rule as the rewrite mode which is the only option where this could have been possible.

Wouldn't have been an issue if it was App Engine where you can configure URL rewrites directly in the app.yaml file. Or a backend server where you can modify with the rule above to automatically rewrite URLs before serving content.

I'm probably missing something and would be grateful for your help.

Thanks


Solution

  • There are two possible solutions for stripping the HTML extension from webpages on a website running on GCP Application Load Balancer using the advanced host and path rule in the rewrite mode:

    Now the file should be served without the .html extension.