link that includess .php? in google app engine

馋奶兔 提交于 2020-01-06 23:45:06

问题


I use app.yaml on google's app engine.

I have a link in my php file which is of this format: profile.php?id=1, which gives me the profile page for user 1. Any idea how to deal with this link in my app.yaml file? This is what I have done:

application: myappl-testing-858585  
version: 1
runtime: php
api_version: 1
threadsafe: yes

handlers:

- url: /profile.php?id=
  script: profile.php?id=

回答1:


Your app.yaml file should only route the paths, like this:

handlers:
- url: /profile
  script: profile.php

(Note that I also removed ".php" from the URL, since you really should not expose the internal file format like ".php", ".html", ".jsp", ".asp", etc. in your URLS... this is an implementation detail of your site, and it's both not good to bother users with it -- it makes for uglier URLs -- and it also makes it more difficult for you to modify your site in the future should you replace one implementation with another).

Then, in your *.php file, you simply use $_GET to test for the existence of / retrieve the ID.

In terms of your site structure, though, you may wish to consider changing the ID to a part of the path rather than a GET parameter if it is always a required parameter (just for URL nicety). In that case, you would register the handler like the following:

handlers:
- url: /profile/(\d+)
  script: profile.php

... so that your URLs looked like "/profile/123" instead of "/profile?id=123".



来源:https://stackoverflow.com/questions/27680438/link-that-includess-php-in-google-app-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!