Nginx重定向到html文件

Nginx重定向到html文件,nginx,Nginx,如何在处理旧浏览器时返回简单的html文件。这是系统中的一个文件。范例 查看nginx文档中的。我想这就是您要找的。您可以使用if语句进行条件重写。(请参阅)用要匹配的用户代理字符串替换条之间的单词,如“foo”。您可能需要一个与默认位置具有不同文档根的位置。使用last对用户是透明的重定向导致302 ### case sensitive http user agent blocking ### if ($http_user_agent ~ (FooSomething|BarElse) ) {

如何在处理旧浏览器时返回简单的html文件。这是系统中的一个文件。范例


查看nginx文档中的。我想这就是您要找的。

您可以使用if语句进行条件重写。(请参阅)用要匹配的用户代理字符串替换条之间的单词,如“foo”。您可能需要一个与默认位置具有不同文档根的位置。使用
last
对用户是透明的<代码>重定向导致302

### case sensitive http user agent blocking  ###
if ($http_user_agent ~ (FooSomething|BarElse) ) {
  rewrite ^ /static-html/your-browser-too-old.html last;
}
### case insensitive http user agent blocking  ###
if ($http_user_agent ~* (foo|bar) ) {
  rewrite ^ /static-html/your-browser-too-old.html last;
}

location /static-html {
  root /var/www/static-html;
}

阅读,但我只是没有找到“返回文件”,我不认为它将是一个
返回
,它将是一个
重定向
到该文件,以便nginx将其渲染。看见
### case sensitive http user agent blocking  ###
if ($http_user_agent ~ (FooSomething|BarElse) ) {
  rewrite ^ /static-html/your-browser-too-old.html last;
}
### case insensitive http user agent blocking  ###
if ($http_user_agent ~* (foo|bar) ) {
  rewrite ^ /static-html/your-browser-too-old.html last;
}

location /static-html {
  root /var/www/static-html;
}