Thanks a lot, please help explain nginx try_files
滿天的星座
滿天的星座 2017-05-16 17:23:58
0
1
657

Who gave the bad review... Fak!!


nginx official documentation on this...but I didn't understand it...

http://nginx.org/en/docs/http/converting_rewrite_rules.html

Just write this as nginx rule

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]


Thank you very much.. Send ShadowSocks

滿天的星座
滿天的星座

reply all(1)
淡淡烟草味

The above rule means that if the file or folder corresponding to the URI does not exist, rewrite it. Apache's %{REQUEST_FILENAME} corresponds to $uri in nginx, so your above rules can be configured with the following try_files

try_files    $uri $uri/  /index.php?_url=/$uri&$args;

The function of try_files is to check whether the files exist in order and return the first found file or folder (a trailing slash indicates a folder). If all files or folders are not found, an internal reset will be performed. Directed to the last parameter.

$args represents the parameters in the url.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template