[英]Google app engine-php: script handler
I try to create php web app using GAE. 我尝试使用GAE创建php网络应用。
In the GAE tutorial, "A script handler executes a PHP script to handle the request that matches the URL pattern. The mapping defines a URL pattern to match, and the script to be executed" 在GAE教程中,“脚本处理程序执行PHP脚本来处理与URL模式匹配的请求。映射定义了要匹配的URL模式以及要执行的脚本”
Now I want to map the url with the file having same name in the folder, eg if the url is /hello.* , it will map the file name hello.php in the folder. 现在,我想使用文件夹中具有相同名称的文件来映射url,例如,如果url是/hello.*,它将在文件夹中映射文件名hello.php。 And if it is /hello1.*, hello1.php in the folder will be responded to the server. 如果是/hello1.*,则文件夹中的hello1.php将响应服务器。
I thought this should be done directly by mapping the name of the url with the name in the folder. 我认为应该直接通过将url名称与文件夹中的名称进行映射来完成此操作。 But if I left empty for the handler in the app.yaml, I got an error. 但是,如果我在app.yaml中为处理程序留空,则会出现错误。
So I want to know how to set up the handler in app.yaml? 所以我想知道如何在app.yaml中设置处理程序?
Use the digit character class to extract digits, use ? 使用数字字符类提取数字,使用? for matching 0 or more times, use .* to match the rest of the url. 要匹配0次或多次,请使用。*匹配其余的url。
- url: /hello(\d?).*
script: hello\1.php
Of course if you just want to match an incoming URL to a file of the same name you can use 当然,如果您只想将传入的URL与同名文件匹配,则可以使用
- url: /(.*)\.php$
script: (\1).php
If you don't want them to specify the .php a the end of the URL then it's 如果您不希望他们在网址末尾指定.php,那么它就是
- url : /(.*)
script: (\1).php
https://developers.google.com/appengine/docs/php/config/appconfig#PHP_app_yaml_Script_handlers https://developers.google.com/appengine/docs/php/config/appconfig#PHP_app_yaml_Script_handlers
handlers:
- url: /hello([0-9]*).(.*)
script: /hello\1.php
I think you would do something similar to that. 我想您会做类似的事情。 The odds are good that the RegEx is incorrect, but you get the idea. RegEx不正确的可能性很高,但是您知道了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.