3

I am hosting a static website with the Google Cloud Platform. I can't figure out how to remove the .html file extension from the URL. Ideally, I would like to have my url read "https://www.website.com/index"

I have tried using .htaccess files, but have not had any luck. I have seen people talking about using a file called "app.yaml", but I am still confused.

What is the best way to remove the .html file extension from a Google Cloud Platform URL?

  • There are different ways of hosting static websites with GCP, using different GCP products. Which one are you using? Or which guide did you follow? – Dan Cornilescu Feb 22 '18 at 22:52
  • I am using the browser storage in order to create a bucket that hosts my static files. – Taylor Parker Feb 23 '18 at 04:52
  • 1
    The `app.yaml` file you are referring to is to be used when oyu use **Appengine Stadard Environment**. On the other side, Google Cloud Storage, the equivalent (making things easy, here) of Amazon S3, is different, and i am looking into the same thing as you. But i don't think that is possible, in case i'll update the thread. – Bruno Ripa Jul 29 '18 at 17:10

1 Answers1

11

I understand you want to remove the .html extension in the links found in the navigation of your site.

The way for you to serve the files as html (after removing the extension file) is to set the file's Content-Type metadata to "text/html".

For example in your Console > Bucket there's a "contact.html" file, perform the following steps:

  1. Click the three dots to the right most part of the list.
  2. Select the Rename option then rename the file to "contact".
  3. Click the three dots again and select the Edit metadata option.
  4. In the form you should see Content-Type field - type in text/html.
  5. Save the changes.

When accessing /contact link/URL, the file should now be served as HTML even after removing the .html extension.

Adi
  • 111
  • 1
  • 4
  • is there anyway to automate this, I can automate removing .html extension but how can I mark 400+ html files in google console – ahmed Sep 06 '22 at 19:05