包括.php的链接?在Google App Engine中
我在Google的应用引擎上使用app.yaml.
I use app.yaml on google's app engine.
我的php文件中具有以下格式的链接: profile.php?id = 1 ,该链接为我提供了用户1的配置文件页面.任何想法如何处理此链接在我的app.yaml文件中?这就是我所做的:
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=
您的app.yaml
文件应仅路由路径,如下所示:
Your app.yaml
file should only route the paths, like this:
handlers:
- url: /profile
script: profile.php
(请注意,我还从URL中删除了".php",因为您实际上不应该公开内部文件格式,例如".php",.html",.jsp",.asp"等).在您的URL中...这是您网站的实现细节,这既不利于用户,也不利于URL的显示-这也使您日后修改网站更加困难您是否应该将另一种实现替换为另一种实现.)
(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).
然后,在您的* .php文件中,只需使用$_GET
来测试是否存在/检索ID.
Then, in your *.php file, you simply use $_GET
to test for the existence of / retrieve the ID.
但是,就您的网站结构而言,如果始终将ID更改为路径的一部分(而不是GET参数),则始终可以将其更改为ID(仅用于URL修饰).在这种情况下,您可以像下面这样注册处理程序:
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
...,以便您的URL看起来像"/profile/123",而不是"/profile?id = 123".
... so that your URLs looked like "/profile/123" instead of "/profile?id=123".