Return 源中的数字不断变化 url
Return with changing number in source url
当用户访问时:
/profile.php?mode=viewprofile&u=[NUMBER FROM 1 TO 4000]
我想要 nginx return:
/memberlist.php?mode=viewprofile&u=[SAME NUMBER]
我该怎么做?谢谢你的帮助。
问题是您需要匹配 /profile.php
和 mode=viewprofile
,这不是微不足道的 nginx
。有多种方法可以实现它。
您可以复制 location ~\.php$
块并在其中添加条件重定向:
location = /profile.php {
if ($arg_mode = viewprofile) {
return 301 /memberlist.php?$args;
}
... # add location ~\.php$ stuff here
}
或者,在 server
块的早期检查 $request_uri(它包含包含查询字符串的原始 URI):
if ($request_uri ~ "^/profile\.php\?mode=viewprofile&") {
return 301 /memberlist.php?$args;
}
有关 if
语句的使用,请参阅 this caution。
当用户访问时:
/profile.php?mode=viewprofile&u=[NUMBER FROM 1 TO 4000]
我想要 nginx return:
/memberlist.php?mode=viewprofile&u=[SAME NUMBER]
我该怎么做?谢谢你的帮助。
问题是您需要匹配 /profile.php
和 mode=viewprofile
,这不是微不足道的 nginx
。有多种方法可以实现它。
您可以复制 location ~\.php$
块并在其中添加条件重定向:
location = /profile.php {
if ($arg_mode = viewprofile) {
return 301 /memberlist.php?$args;
}
... # add location ~\.php$ stuff here
}
或者,在 server
块的早期检查 $request_uri(它包含包含查询字符串的原始 URI):
if ($request_uri ~ "^/profile\.php\?mode=viewprofile&") {
return 301 /memberlist.php?$args;
}
有关 if
语句的使用,请参阅 this caution。