首页 > 技术文章 > nginx如何设置访问跳转到一个固定页面

dantes91 2015-08-04 21:09 原文

方法一

server

{
    listen 80 ;
    server_name  www.xxx.com xxx.com; 
    index   test.html  index.html index.htm index.php;   #直接放置index下
    root /path/to/;

 

}

 

方法二

 

server

{
    listen 80 ;
    server_name  www.xxx.com xxx.com;
    index  index.html index.htm index.php;
    root /path/to/;
    
if ($document_uri !~ 'test.html' ){
     rewrite  ^/(.*)$  http://www.xxx.com/test.html  permanent;   }

 

}

推荐阅读