我正在学习如何将现有的PHP项目移至gCloud。 同样,我创建了一个AppEngine项目,并将代码放置在那里。
除了PHP文件,一切似乎都可以正常工作。
当我启动项目时,索引文件将启动(如app.yaml中所指定),然后在PHP应该执行的位置,它将呈现index.html文件。这会导致致命的索引调用循环PHP调用索引调用PHP:(
我确定我的app.yaml错误,但是无法确定问题出在哪里。
我的Yaml看起来像这样:
runtime: php55
api_version: 1
threadsafe: true
handlers:
- url: /dialpad_research/(.*\.(appcache|manifest))
mime_type: text/cache-manifest
static_files: dialpad_research/static/\1
upload: dialpad_research/static/(.*\.(appcache|manifest))
- url: /dialpad_research/static
static_dir: dialpad_research/static
# image files
- url: /dialpad_research/static/(.*\.(bmp|gif|ico|jpeg|jpg|png))
static_files: static/\1
upload: static/(.*\.(bmp|gif|ico|jpeg|jpg|png))
# dialpad root
- url: /dialpad_research.*
static_files: dialpad_research/static/index.html
upload: dialpad_research/static/index.html
- url: /dialpad_research/api/(.+\.php)$
script: api/\1
感谢您的帮助。
文件夹结构是这样的:
Root
|
---- app.yaml
---- dialpad_research (folder)
|
---- static (folder with index file)
---- api (folder with PHP files)
答案 0 :(得分:2)
您必须注意正则表达式匹配。网址格式:
- url: /dialpad_research/static
将匹配:
- url: /dialpad_research/static(anything to follow)
因此,它永远不会到达以下处理程序:
- url: /dialpad_research/static/(.*\.(bmp|gif|ico|jpeg|jpg|png))
相同于:
- url: /dialpad_research.*
在那之后,它永远无法到达:
- url: /dialpad_research/api/(.+\.php)$
为处理程序重新排序,以免它们短路。
接下来,/api/
和/static/
不在根目录,因此您的路径不正确。见下文:
handlers:
- url: /dialpad_research/(.*\.(appcache|manifest))
mime_type: text/cache-manifest
static_files: dialpad_research/static/\1
upload: dialpad_research/static/(.*\.(appcache|manifest))
# image files
- url: /dialpad_research/static/(.*\.(bmp|gif|ico|jpeg|jpg|png))
static_files: dialpad_research/static/\1
upload: dialpad_research/static/(.*\.(bmp|gif|ico|jpeg|jpg|png))
- url: /dialpad_research/api/(.+\.php)$
script: dialpad_research/api/\1
- url: /dialpad_research/static
static_dir: dialpad_research/static
# dialpad root
- url: /dialpad_research.*
static_files: dialpad_research/static/index.html
upload: dialpad_research/static/index.html