简体   繁体   中英

Can dynamic url parameters be handled in app.yaml for google appengine for php?

Is it possible to use app.yaml in google app engine for php to convert database driven pages with url parameters (?= after php page in the url) to a more human readable form? If not app.yaml is there another way?

For example: www.testpage.com/shoes?id=red-shoes

converted to something like: www.testpage.com/shoes/red-shoes

As far as I know it cannot be done with app.yaml. The reason is, if you took something like what you're describing, eg:

handlers:
- url: /(.*?)/(.*)
  script: /\1?id=\2

App Engine would correctly identify that pattern /shoes/red-shoes and route it to /shoes?id=red-shoes. Except it treats /shoes?id=red-shoes as the filename (which obviously doesn't exist) instead of a script + query string.

So, the way to accomplish what you're trying to do would be something like this:

handlers:
- url: /(.*?)/(.*)
  script: /mydbhandler.php

The pattern /(. ?)/(. ) matches patterns like /shoes/red-shoes and sends all such requests to /mydbhandler.php. Inside /mydbhandler.php you should inspect $_SERVER["REQUEST_URI"] which will be "/shoes/red-shoes" and handle it from there inside your PHP code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM