黄石网站建设

黄石网页设计

黄石网站制作

黄石网络推广

黄石做网站的公司

黄石建站

博强科技

您的当前位置 >> 主页 > 新闻动态 > 网站建设技术 >

网站建设技术

新闻图案

网站制作

LNMP环境301重定向的方法演示

中国网络营销推广专家

  本站绑定了net8000.com和www.net8000.com,这样对搜索引擎很不友好,导致域名的PR值分散到两个URL上了。301重定向就可以解决这个问题,把不带www和带www的域名合并到一起。

    下面以本站为例,做了LNMP环境下的nginx域名301重定向教程。

方法/步骤

  1. 直接用WinSCP编辑器打开 /usr/local/nginx/conf/vhost/www.net8000.com.conf 这个配置文件,代码如下:

     

     

    server

         {

             listen       80;

             server_name net8000.com www.net8000.com;

             index index.html index.htm index.php default.html default.htm default.php;

             root  /home/wwwroot/net8000.com;

     

             include typecho.conf;

             location ~ .*\.(php|php5)?$

                     {

                             fastcgi_pass  unix:/tmp/php-cgi.sock;

                             fastcgi_index index.php;

                             include fcgi.conf;

                     }

     

             location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

                     {

                             expires      30d;

                     }

     

             location ~ .*\.(js|css)?$

                     {

                             expires      12h;

                     }

     

             access_log off;

         }

     

  2. 现在把 server_name net8000.com www.net8000.com; 这行的net8000.com 删掉。

  3.  再在后面加上下面代码:

    server {

       server_name net8000.com;

       rewrite ^(.*) http://www.net8000.com$1 permanent;

    }

     

  4. 最终效果见下图:

    手把手的教你LNMP环境301重定向的方法
  5. 5

    改完后重启nginx就生效了。虽然做了301重定向,但是DNS处还是要做A记录解析的。完成后,试试效果,打开net8000.com就会自动跳转到www.net8000.com。

收缩

QQ在线客服

  • 在线咨询
  • 客服001
  • 客服001
  • 售后服务
  • 客服001
黄石建站

QQ在线客服

首 页 新闻动态 案例展示 服务范围 关于我们 联系我们 客户需求 网站地图
电话:13597671188 QQ:494602646 黄石网站建设-博强科技 Copyright © 2013-2014 All Rights Reserved 鄂ICP备12000085号
博强科技版权所有 未经允许不得私自发布转载