侧边栏壁纸
博主头像
欧阳博客

行动起来,活在当下

  • 累计撰写 140 篇文章
  • 累计创建 124 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

Nginx跳转实例

欧阳
2016-07-19 / 0 评论 / 0 点赞 / 2 阅读 / 0 字

网站有时候有多个域名,所以需要做跳转 有时候也需要顶级直接跳转到www上,现就记录nginx跳转实例。

server  
    {  
        listen       80;  
        server_name www.1.com www.22.com.cn www.333.com;  
        index index.html index.htm index.php;  
        root /home/www;  
  
        if ($host = 'www.22.com.cn' ) {  
                rewrite ^/(.*)$ http://www.1.com/$1 permanent;  
        }  
        if ($host = '333.com' ) {  
                rewrite ^/(.*)$ http://www.1.com/$1 permanent;  
        }  
        if ($host = '22.com.cn' ) {  
                rewrite ^/(.*)$ http://www.1.com/$1 permanent;  
        }  

break 中止Rewirte,不在继续匹配; redirect 为302临时重定向的HTTP状态; permanent 为301永久重定向的HTTP状态。

0

评论区