How to construct a app.yaml file?
Your app.yaml is looking good; it's just incomplete.
You've defined that /
and /main
map to your main.php script, and that works fine.
But when the user's browser requests /login.php
, App Engine looks in app.yaml and does not find any route that matches, so you get this 404 error.
To handle this particular case, you can another entry with url: /login.php
and script: login.php
.
Then I would look through your application and make sure you're not missing any other routes.
You also may need to use wildcards in your URLs in app.yaml. Otherwise, if your application ever sends the user to a URL like /main/subpage
, it will not go to the main.php handler because it matches no routes in app.yaml. In this case you might want to use url: /main.\*
, as an example. Or you can use a catchall /.*
handler at the end of your app.yaml.
You can learn about these wildcards and the other app.yaml options on the PHP app.yaml reference page: https://developers.google.com/appengine/docs/php/config/appconfig
(You don't need wildcards for your stylesheets, javascript, and images, though, because you've used static_dir for those.)
Here's mine, it may help. Pcode
is just one of my folders (not sure if you need to define folders but I just left it there anyway):
application: theclearview1
version: 10
runtime: php
api_version: 1
handlers:
- url: /(.*\.(htm$|html$|css$|js$))
static_files: \1
upload: (.*\.(htm$|html$|css$|js$))
application_readable: true
- url: /css
static_dir: css
- url: /js
static_dir: js
- url: /(.*\.(ico$|jpg$|png$|gif$))
static_files: \1
upload: (.*\.(ico$|jpg$|png$|gif$))
application_readable: true
- url: /Pcode/(.+)
script: Pcode/\1
- url: /(.+)
script: \1
- url: /.*
script: index.php
Basically, I think the following lines will run similar to a regular php host like hostgator
, godaddy
etc.:
handlers:
- url: /(.*\.(htm$|html$|css$|js$))
static_files: \1
upload: (.*\.(htm$|html$|css$|js$))
application_readable: true
- url: /(.*\.(ico$|jpg$|png$|gif$))
static_files: \1
upload: (.*\.(ico$|jpg$|png$|gif$))
application_readable: true
- url: /(.+)
script: \1
- url: /.*
script: index.php