无法获取Root html(/index.html)。返回404

时间:2011-07-20 18:24:45

标签: python google-app-engine http-status-code-404

目录结构是 -

MyApplication (Project Dir)

-static
   --inside static, I got different dirs containing images, css, htmls, etc
-some other dirs
-app.yaml
-index.py
-index.html

app.yaml的内容为 -

application: MyApplicationID
version: 1
runtime: python
api_version: 1

handlers:

- url: /favicon.ico
  static_files: static/images/favicon.ico
  upload: static/images/favicon.ico
  mime_type: image/x-icon

- url: /robots.txt
  static_files: static/robots.txt
  upload: static/robots.txt

- url: /static
  static_dir: static  
  secure: optional

- url: /projects
  static_dir: projects  
  secure: optional

- url: /about
  static_dir: about  
  secure: optional

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

- url: /.*
  script: index.py
  secure: optional

一切正常,但如果html页面上的任何内容重定向到“index.html”,我会找不到一个页面(“GET /index.html HTTP / 1.1”404 - )错误。我尝试了这个 - https://gist.github.com/873098,但仍然没有运气。我尝试了其他线程的其他建议,但仍然没有运气。如果我删除 - url:/ 仍然没有运气。请指教。

2 个答案:

答案 0 :(得分:1)

对于“/index.html”的请求将由index.py处理,给定app.yaml的内容。据推测,您在该文件中没有“/index.html”的处理程序。

如果您希望index.html为“/index.html”的请求投放,请添加与该网址匹配的app.yaml映射(或者,只需重定向到“/”而不是“/index.html”。该网站,不那么难看)

答案 1 :(得分:1)

另一个人是对的,您没有网址 index.html的条目,例如

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

编辑2:为了清楚起见,无论static_files行上有什么内容,即使http://mysite.com/index.html行包含子目录,这仍会产生static_files的网址。