【问题标题】:How to redirect queries in Nginx如何在 Nginx 中重定向查询
【发布时间】:2014-12-11 08:29:12
【问题描述】:

如何在 Nginx 中重定向:

www.toutdefrance.nl/tf_main.php?thema=14&status=3

到这里:

www.toutdefrance.nl/vakantie-in-frankrijk/

在 Nginx 中

到目前为止,这是我的配置:

if ($host = "toutdefrance.nl") {
  rewrite ^ $scheme://www.toutdefrance.nl$uri permanent;
}

if ($host = "toutdefrance.be") {
  rewrite ^ $scheme://www.toutdefrance.nl$uri permanent;
}
location = /tf_main.php {
  rewrite ^(.*)$ /;
}
location / {
  try_files $uri $uri/ @modx-rewrite;
}

谢谢 哈比

【问题讨论】:

    标签: nginx


    【解决方案1】:
    if ($host = "toutdefrance.nl") {
      rewrite ^ $scheme://www.toutdefrance.nl$uri permanent;
    }
    
    if ($host = "toutdefrance.be") {
      rewrite ^ $scheme://www.toutdefrance.nl$uri permanent;
    }
    

    请阅读这个http://wiki.nginx.org/Pitfalls#Server_Name - 服务器块好多了,所以

    server {
       server_name toutdefrance.nl toutdefrance.be;
       return 301 $scheme://www.toutdefrance.nl$request_uri;
    }
    

    并重定向:

    location = /tf_main.php {
       set $point "$arg_thema:$arg_status";
       if ($point = "14:3") {
          return 301 /vakantie-in-frankrijk/;
       }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-04
      • 2012-05-28
      • 2019-01-03
      • 1970-01-01
      • 2016-07-12
      • 2012-05-04
      • 2021-04-26
      • 2022-01-10
      相关资源
      最近更新 更多