php - Building cloud engine yaml handler
Get the solution ↓↓↓Solution:
You mentioned that you're not a developer so I'll divide this answer in parts so I can cover all the things I've found.
1. Wildcards
Wildcards are special characters that can stand in for unknown characters in a text value and are handy for locating multiple items with similar, but not identical data.
The symbol * matches any number of characters. You can use the asterisk (*) anywhere in a character string.
Example: "wh*" matches with what, white, and why, but not awhile or watch.
Understanding this will help us for the further sections.
2. About the app.yaml file
You're having issues with your app.yaml for PHP 5. This file specifies how URL paths correspond to request handlers. In other words: It's used to tell your app which script will run when an user enteres certain URL's or web address.
For instance, the following:
- url: /login.*
script: login.php
can be read as: "Any URL that matches at the end with /login.*, will be handled by the PHP script login.php"
Inside the login.php is part of your app's logic.
3. Calling certain paths
A file path describes the location of a file in a web site's folder structure.
Absolute File Paths: It describes the full address(URL) to access an internet file. Example: https://mywebsite.com/web-content/folder/awesome.html
Relative File Path: It describes the path of the file relative to the location of the current web page file. Example: folder/awesome.html
4. Serving static files
You can also serve files like .png, .jpg or .gif from your app.yaml file. For instance, the following:
- url: /(.*\.(gif|png|jpg))$
static_files: static/\1
upload: static/.*\.(gif|png|jpg)$
Can be read as: "All the requests that ended with gif, png or jpg will return the file name with that extension".
There are other ways to call files from your website. For instance, if you write, https://myweb.com/new.html, you might get the file new.html as a response.
5. Your scenario
I'd like you to put special attention at the following part in your file:
- url: /.*
script: box.html
This can be read as: "Any requests that doesn't match with any of the listed ones", will be redirected to box.html"
Now take a look at:
- url: /001100110011other.html(.+)
script: 001100110011other.html
When trying to enter to "/other.html", it doesn't match with the Regular expression of that URL, so you get redirect tobox.html
, the default one.
6. Recommendations
To handle what responses or pages you'd like to see within your app's logic. For instance Handling HTTP requests from Laravel.
Use the app.yaml file's configurations just to indicate which file you want to use to process or handle the request instead of serving html files from there.
I hope this is helpful!
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: trying to access array offset on value of type null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.