search

Home  >  Q&A  >  body text

Thanks a lot, please help explain nginx try_files

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

滿天的星座滿天的星座2828 days ago678

reply all(1)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-16 17:25:58

    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.

    reply
    0
  • Cancelreply