如何在Nginx中重定向查询

时间:2014-12-08 21:14:47

标签: nginx

如何在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;
}

日Thnx HUrby

1 个答案:

答案 0 :(得分:0)

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