相当于Apache MultiViews的nginx?

如果你把它放在你的.htaccess文件中

Options MultiViews 

你有这些文件

 stuff/ howto.html index.php items.php 

那么所有这些url都可以工作

 /stuff/ # brings up /stuff/index.php. # Yes, this would have worked `# even without MultiViews /stuff/howto # brings up /stuff/howto.html. #`This would not have # worked without MultiViews, # although you could have done # it with a Rewrite rule, too /stuff/items # brings up /stuff/items.php /stuff/items/1234 # brings up /stuff/items.php, # and sets $_SERVER['PATH_INFO'] # to '/1234' /stuff/items/2010/03/01/how-to-plant-a-garden # brings up /stuff/items.php, and # sets $_SERVER['PATH_INFO'] # to '/2010/03/01/how-to-plant-a-garden'. # If my file layout was different, # like /stuff/items/2010.php, # then it would have brought up # 2010.php, and given it the PATH_INFO # string of '/03/01/how-to-plant-a-garden' # So it seems Apache searches the string # from right to left for a file 

MultiViews放在.htaccess文件中比使用重写规则短得多。

但现在我正在看nginx,我还没有find相同的。 它不必这么短。 我知道try_files会照顾那些没有PATH_INFOstring。 但是对于那些使用PATH_INFO的人来说,唯一的办法就是为每个PHP文件重写规则,尤其是那些在PATH_INFO中使用斜杠的规则。