The default document in Google App Engine

Is it possible to specify the equivalent of the default document for directories in Google App Engine, so that the transition to this directory is automatically redirected to its index.html, for example, if it contains one?

If I have this in my app.yaml:

- url: /demos static_dir: demos 

and the demos directory contains the index.html page, how can I say that App Engine is automatically redirected to this page?

+7
source share
4 answers

App Engine uses regular expression matches in the request path to determine which script to invoke or the document to serve. If you have only one index document, you can do it as follows:

 - url: /demos/ static_files: demos/index.html upload: demos/index\.html 

More generally, you can define static files for paths ending in slashes ("directories"), for example:

 - url: /(.*)/ static_files: \1/index.html upload: .*/index\.html 
+9
source

I got it to work using it in my yaml.

 - url: /(.+) static_files: static/\1 upload: static/(.+) - url: / static_files: static/index.html upload: static/index.html 

Replace the static demos and you should be installed. It redirects the empty domain to index.html and others to a static folder.

+3
source

For GAE / J, add the following to your web.xml file.

 <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> 

www.example.com/test/ will now serve www.example.com/test/index.html

+1
source
 - url: /demos(/.+|)/ static_files: demos\1/index.html upload: demos/(.+/|)index\.html - url: /demos/ static_dir: demos 
0
source

All Articles