298610601 发表于 2012-4-16 11:48:34

nginx 301重定向的配置 100%无错,已测试

配置文件路径/usr/local/nginx/conf/vhost/zmanhua.com.conf

vi zmanhua.com.conf

代码如下:server
      {
                listen       80;
                server_name www.zmanhua.com;
                index index.html index.htm index.php default.html default.htm default.php;
                root/home/wwwroot/zmanhua.com;

                include zmanhua.conf;
                location ~ .*\.(php|php5)?$
                        {
                              fastcgi_passunix:/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;
      }
server {
server_name zmanhua.com;
rewrite ^(.*) http://www.zmanhua.com$1 permanent;
}之后重启/root/lnmp restart 就好了~:victory:

298610601 发表于 2012-4-16 15:11:56

注意一点:前面的server name只能包含带www的哦,不带www的写下面

flydream00 发表于 2012-7-4 11:01:22

我按照这个方法做的,百度还是收录的不一样,排名也不一样,快照也不一样
页: [1]
查看完整版本: nginx 301重定向的配置 100%无错,已测试