简体   繁体   中英

Google Cloud HTTPS Load Balancer URL Rewrite To Remove .html Extension

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM