基于特定查询字符串的Nginx重定向

时间:2018-12-16 16:42:50

标签: regex wordpress nginx redirect

我正在尝试根据特定的查询字符串进行重定向:

https://foo.com/wp-login.php?action=registerhttps://foo.com/account/

location ~* /(wp-login\.php) {
        if ($query_string = "action=register") {
                rewrite ^ https://foo.com/account/ permanent;
        }

    limit_req zone=xwplogin burst=1 nodelay;
    #limit_conn xwpconlimit 30;
    auth_basic "Private";
    #auth_basic_user_file /home/nginx/domains/foo.com/htpasswd_wplogin;
    include /usr/local/nginx/conf/php-wpsc.conf;
    # https://community.centminmod.com/posts/18828/
    #include /usr/local/nginx/conf/php-rediscache.conf;
}

1 个答案:

答案 0 :(得分:0)

尝试一下:

server {
  # ...
  rewrite ^/wp-login\.php\?action=register$ https://foo.com/account/ permanent;
  # ...
}