NGINX如何处理特定的url匹配为html而不是php

问题描述 投票:0回答:1

我得到了文件名的静态页面,如:atatat.php?article = 3

我需要将它们作为html处理。全部在文件名中匹配“atatat.php”。

和其他页面一样,常规* .php没有“atatat.php”在url进程中像往常一样匹配php,是否可以使用nginx配置?

nginx nginx-config
1个回答
0
投票

您可以使用nginx正则表达式匹配:

location ~* atatat.php {
  // this will match any url that contains `atatat.php`
  // do whatever you want with them here
}

location ~* [^(atatat)].php {
  // this will match any url that **doesn't** contain `atatat.php`
  // do whatever you want with them here
}

~*告诉nginx将下一部分视为不区分大小写的正则表达式。如果您需要区分大小写,请使用~(删除星号)。

© www.soinside.com 2019 - 2024. All rights reserved.