Guy
Guy

Reputation: 876

Google App Engine app.yaml for PHP scripts

I'm trying to get my app.yaml file to send URLs as one would expect them to work. Currently, my app.yaml file looks as such:

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

  # Serve php scripts.
- url: /(.+\.php)
  script: \1

- url: /.*
  script: main.php

This works ok. I go to a URL, click a link and it redirects and loads the page properly. The problem is when I try to access a .php file that isn't there. It gives me a warning and a bunch of errors. I would like this to redirect to a specific page, such as a log in page or 404 page. Any idea on how to do that? Thanks!

Upvotes: 2

Views: 2882

Answers (1)

Andrew J
Andrew J

Reputation: 2001

This yaml file is:

1) configured to direct any filepath ending in .php to the corresponding file. eg. the URL \bellows.php will be redirected to the file <my_app_directory>\bellows.php

2) any URL not matching the above rule will be redirected to <my_app_directory>/main.php

Thus when you hit any URL that doesn't end in .php it will redirect to main.php - this is likely what is generating the errors.

Upvotes: 1

Related Questions