Nginx重定向为/stargate/index.php?seite=sga

时间:2016-02-06 14:13:42

标签: nginx

我想重定向(只有这个特殊的旧网址)

/stargate/index.php?seite=sga

带301到

/stargate-atlantis-serienubersicht

我该怎么做?

由于 kay899

1 个答案:

答案 0 :(得分:0)

您可以将nginx中的查询参数引用为$arg_seite

location = /stargate/index.php {
  if ($arg_seite = 'sga'){
    return 301 $scheme://your_domain.com/stargate-atlantis-serienubersicht;
  }
  # here goes config for handling that index.php if request came with other parameters
  # or if not needed just:
  return 404;
  # this is important, otherwise will return 404 for both branches
}

如果不需要,上面也会重写?seite=sga&some-other-param=123 - 测试$args变量中未解析的参数

相关问题