Reputation: 785
I try to create php web app using GAE.
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"
Now I want to map the url with the file having same name in the folder, e.g. if the url is /hello.* , it will map the file name hello.php in the folder. And if it is /hello1.*, hello1.php in the folder will be responded to the server.
I thought this should be done directly by mapping the name of the url with the name in the folder. But if I left empty for the handler in the app.yaml, I got an error.
So I want to know how to set up the handler in app.yaml?
Upvotes: 0
Views: 445
Reputation: 7054
Use the digit character class to extract digits, use ? for matching 0 or more times, use .* to match the rest of the 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: /(.*)\.php$
script: (\1).php
If you don't want them to specify the .php a the end of the URL then it's
- url : /(.*)
script: (\1).php
Upvotes: 1
Reputation: 605
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.
Upvotes: 0