Nginx, .Htaccess and try_files



我需要将这个htaccess文件转换为nginx的try_files,但我一辈子都做不到。有人能帮忙吗?

Options +FollowSymlinks
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^img-(.*).html img.php?id=$1 [L]
RewriteRule ^slide-(.*).html slider.php?id=$1 [L]
RewriteRule ^page-(.*).html page.php?name=$1 [L]
RewriteRule ^contact.html$ contact.php [QSA,L,NC]

此处不需要try_files:

rewrite ^/img-(.*).html$ /img.php?id=$1 last;
rewrite ^/slide-(.*).html$ /slider.php?id=$1 last;
rewrite ^/page-(.*).html$ /page.php?name=$1 last;
rewrite ^/contact.html$ /contact.php last;

最新更新