1

I've read the Traffic management overview for global external HTTP(S) load balancers URL maps overview but do not see how to do the following:

https://example.com/page ----> https://example.com/page.html

Is it possible to "remove" the .html extension from my URL with Google's global external HTTP(S) load balancer?

My website is hosted on Google Cloud Storage (bucket). I understand that I can use gsutil to set metadata on files to type:text/html and that is a viable workaround, however I would need to script that and I spent a couple of hours looking at that but never got it figured out. The script would basically need to recursively list all files with .html extension then rename them removing the file extension then set the metadata.

Ronnie Royston
  • 16,778
  • 6
  • 77
  • 91
  • How is your website hosted? What GCP Products are you using? Kindly update your question with further details. – James S Jan 19 '23 at 18:10

1 Answers1

1

URL rewrites allow you to present external users with URLs that are different from the URLs that your services use. Although it says that it provides URL shortening, extension removal isn't done through the Load Balancer, but rather by setting the file's Content-Type metadata to "text/html" or using App engine or Firebase hosting to serve a static HTML website and hide HTML extension. The latter suggestion was discussed in another stackoverflow post

 url: /contact
  static_files: www/contact.html
  upload: www/contact.html
James S
  • 1,181
  • 1
  • 7
  • 1
    Right. I abandoned Cloud Storage for hosting static files, and switched over to App Engine running Node/Express. Cloud Storage works fine for static hosting as long as you don't have subdirectories. – Ronnie Royston Jan 21 '23 at 02:55