第一种:

server
{
    location / {
        rewrite ^/(.*)$ http://www.baidu.com/$1 permanent;
    }
}

第二种:

server
{
    location / {
        return 301 http://www.baidu.com;
    }
}

第三种:

server
{
    location / {
        #default_type 指定显示格式,不可缺少,!-f /home/999 主要用于使条件为真,因为/home下并没有文件夹999
        default_type text/html;
        if (!-f /home/999) {
            return 200 "<html><script>window.location.href='http://www.baidu.com'</script></html>";
        }
    }
}

 

相关文章:

  • 2021-10-12
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2021-07-07
  • 2022-12-23
  • 2021-08-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
  • 2021-09-01
  • 2021-10-05
  • 2022-12-23
相关资源
相似解决方案