I recently migrated a site to the flex environment from bluehost. With this migration, I'm aware that I need to configure my nginx-app.conf file to serve scripts/files in the way that I want, but I don't know how to do this.
I want to mimic hosting providers like bluehost, godaddy, hostgator etc... Where I can deploy a script to domain.com/path/
and when a request is made to that path: the domain.com/path/index.php
is loaded if it exists, or it falls back to index.html
or throws a 404 error
In addition: if a request is made directly to a script like so: domain.com/path/myscript.php
then the appropriate myscript.php file is loaded if it exists, or throws a 404 error.
I have attempted to write my nginx-app.conf
file as follows:
location /~* { # try to serve file directly, fallback to front controller try_files $uri /index.php$is_args$args; }
But when I click on any links after a deploy, it just stays on the same page.
After just monkeying around for ages, and dealing with the unbearably slow deployment times on the flex environment, I was able to come up with the following that works.
location / {
try_files $uri?$args $uri/index.php?$args;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.