我需要一些关于nginx regex重写的帮助。
这
https://www.website.com/downloads.php?do=file&id=4798至
https://www.website.com/index.php?resources/4798/这
https://www.website.com/showthread.php?t=4449128至
https://www.website.com/index.php?threads/4449128/这(棘手的问题)。
https://www.website.com/forumdisplay.php?f=12&prefixid=8至
https://www.website.com/forums/pc-probs.12/?prefix_id=8感谢大家的帮助。
@Miguel Mota
标记
发布于 2017-06-26 14:22:28
尝尝这个。这是基于你的例子的。
location / {
# A
if ($args ~* "id=(\d+)") {
set $id $1;
set $args '';
rewrite ^/downloads\.php(.*)$ /index.php?resources/$id/ permanent;
}
# B
if ($args ~* "t=(\d+)") {
set $t $1;
set $args '';
rewrite ^/showthread.php(.*)$ /index.php?threads/$t/ permanent;
}
# C
if ($args ~* "prefixid=(\d+)") {
set $pfid $1;
}
if ($args ~* "f=(\d+)") {
set $f $1;
set $args '';
rewrite ^/forumdisplay.php(.*)$ /forums/pc-probs.$f/?prefix_id=$pfid/ permanent;
}
}https://stackoverflow.com/questions/44750493
复制相似问题