Tanu Gupta
Tanu Gupta

Reputation: 612

google app engine - set 404 page for php

I have create a dynamic page for error code 404. How can I set the same in app.yml?

I tried setting error handlers in app.yml but its not working.

error_handlers:
- error_code: 404
  file: page404.php

It keeps on giving:

The url <wrong url> does not match any handlers.

Upvotes: 1

Views: 1422

Answers (2)

Tim Hoffman
Tim Hoffman

Reputation: 12986

A couple of things to note.

You don't have to use error handlers to deal with 404. and there is no specific 404 error handler. There is only the following error_handler types

a default handlers and

over_quota, which indicates the app has exceeded a resource quota; dos_api_denial, which is served to any client blocked by your app's DoS Protection configuration; timeout, served if a deadline is reached before there is a response from your app.

See docs https://developers.google.com/appengine/docs/php/config/appconfig#Custom_Error_Responses

In addition a custom error handler will not render a php script they need to be static html, so if you want your 404 response page to run php then you need to use a normal handler that catches anything not matching one of your handlers, as per the other answer.

Upvotes: 1

Tanu Gupta
Tanu Gupta

Reputation: 612

Got the solution:

Add below setting at the end of app.yml. After checking all the formats, it will match the below pattern and throw 404 error page.

- url: /.*
  script: page404.php

Upvotes: 3

Related Questions