Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 重写:如何在nginx配置中区分两个相似的位置_Regex_Nginx_Rewrite - Fatal编程技术网

Regex 重写:如何在nginx配置中区分两个相似的位置

Regex 重写:如何在nginx配置中区分两个相似的位置,regex,nginx,rewrite,Regex,Nginx,Rewrite,我有两个类似的站点,我现在要合并成一个,所以我将使用启用的nginx配置将链接从一个重定向到另一个 由于“转发自”网站使用“漂亮的URL”,我只是做了如下规则: location /about/about-us/ { rewrite ^(.*)$ http://www.thenewwebsite.com/aboutus.htm permanent; } /fruit/, /fruit/apples/, /fruit/bananas/, /fruit/12/ 但是,我有这样的地址结构: loc

我有两个类似的站点,我现在要合并成一个,所以我将使用启用的nginx配置将链接从一个重定向到另一个

由于“转发自”网站使用“漂亮的URL”,我只是做了如下规则:

location /about/about-us/ { rewrite ^(.*)$ http://www.thenewwebsite.com/aboutus.htm permanent; }
/fruit/, /fruit/apples/, /fruit/bananas/, /fruit/12/
但是,我有这样的地址结构:

location /about/about-us/ { rewrite ^(.*)$ http://www.thenewwebsite.com/aboutus.htm permanent; }
/fruit/, /fruit/apples/, /fruit/bananas/, /fruit/12/
当我使用相同的位置重写公式(导致4个位置行)时,general/fruit/address似乎否决了更具体的地址(/fruit/bananas/)


我应该怎么写呢?

较长的前缀优先,但您需要指定所有前缀(包括尾随的
/
)。有关语法和处理规则,请参见。能否显示实际的位置定义及其顺序?