现在我有一个像.htaccess这样的代码,如下所示:
RewriteCond %{QUERY_STRING} ^(.*)&?fbclid=[^&]+&?(.*)$ [NC]
RewriteRule ^(.*)$ /$1?%1%2 [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)&?fb_action_ids=[^&]+&?(.*)$ [NC]
RewriteRule ^(.*)$ /$1?%1%2 [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)&?fb_comment_id=[^&]+&?(.*)$ [NC]
RewriteRule ^(.*)$ /$1?%1%2 [R=301,L]
请帮我将其转换为nginx谢谢
整个查询字符串可用作$args
变量。您可以使用 if
语句测试变量。
例如:
if ($args ~ ^(.*)&?fbclid=[^&]+&?(.*)$) {
return 301 $uri?$1$2;
}
if ($args ~ ^(.*)&?fb_action_ids=[^&]+&?(.*)$) {
return 301 $uri?$1$2;
}
if ($args ~ ^(.*)&?fb_comment_id=[^&]+&?(.*)$) {
return 301 $uri?$1$2;
}