【问题标题】:nginx redirect based on specific query string基于特定查询字符串的 nginx 重定向
【发布时间】:2019-05-17 04:13:14
【问题描述】:

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

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;
}

【问题讨论】:

  • 问题是什么?你得到了什么?
  • 什么都没有发生,没有重定向发生。

标签: regex wordpress nginx redirect


【解决方案1】:

试试这个:

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

【讨论】:

  • @JCats 我不敢相信它不起作用!你能添加服务器块吗?
  • 是的,我已将其添加到位置/块
  • @JCats 或许 this 能帮到你
猜你喜欢
  • 2018-08-18
  • 1970-01-01
  • 2019-01-03
  • 2017-10-04
  • 1970-01-01
  • 2012-07-21
  • 2018-11-20
  • 1970-01-01
相关资源
最近更新 更多