0

I’m new to google app engine and I’m trying to configure my app.yaml file for a web application which utilizes php and ajax. I’ve got the application running in the PHP SDK using the following yaml file:

application: foobar
version: 1
runtime: php
api_version: 1

handlers:
- url: /stylesheets
  static_dir: stylesheets

- url: /
  script: index.php

- url: /ajax.php
  script: ajax.php

- url: /index.*
  script: index.php

- url: /about.*
  script: about.php

- url: /terms.*
  script: terms.php

- url: /contact.*
  script: contact.php

- url: /update.*
  script: update.php
  login: required
  secure: always

- url: /login.*
  script: login.php
  login: required
  secure: always

- url: /.*
  script: index.php

Although this is fundamentally working I’ve got a feeling I’m doing something wrong because I don’t really want to provide access to ajax.php since it is purely for ajax processing. When I type ‘ajax.php’ into the browser in IE9 I’m prompted to open or save ‘ajax.js’, which contains processing code from the ajax file. In other browsers the same code is dumped directly onto the webpage.

How can I allow ‘ajax.php’ file to be accessed by ‘index.php’ but avoid this issue?

user2468499
  • 105
  • 6
  • I'm guessing that this is a matter of setting the Content-Type in the response (e.g., to 'application/json'). Now how to do that in PHP? I don't do much PHP, but I imagine that answer is in https://developers.google.com/appengine/docs/php/#PHP_Responses – Dave W. Smith Oct 13 '13 at 16:15
  • Looks like this guy is doing something similar: http://stackoverflow.com/questions/16663771/how-to-reference-nested-requires-in-app-yaml-for-app-engine-php/16664295#16664295 – Stagleton Oct 15 '13 at 17:49
  • Thanks for your input guys. I obviously need to do some more in-depth reading to better understand the issue and possible options. I’m also looking at non-yaml options such as discussed here: http://stackoverflow.com/questions/1756591/prevent-direct-access-to-file-called-by-ajax-function – user2468499 Oct 16 '13 at 15:21
  • You don't need to put every php file in your app into the app.yaml file. Just the ones that you want to access from the client side. If your script is called by another script only then don't put it in the app.yaml file at all. – Stuart Langley Nov 26 '13 at 06:22
  • Thanks for your assistance, however when I try that my index script fails to connect to the ajax file and instead dumps javascript onto the page. – user2468499 Nov 28 '13 at 14:29

0 Answers0