全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
12
返回列表 发新帖
楼主: __蛋丶碎
打印 上一主题 下一主题

Nginx 1.8.0 301你们对吗?

[复制链接]
11#
 楼主| 发表于 2015-5-22 16:44:16 | 只看该作者
junhan 发表于 2015-5-22 12:06
不知你怎么搞的,我使用LNMP,该域名全部配置如何下,你试试:

server
        {
                listen 80;
                #listen [::]:80;
                server_name www.baidu.com baidu.com img.baidu.com;
                index index.html index.htm index.php default.html default.htm default.php;
                root  /home/wwwroot/www.baidu.com;

                include baidu.conf;
                #error_page   404   /404.html;
                location ~ [^/]\.php(/|$)
                        {
                                # comment try_files $uri =404; to enable pathinfo
                                try_files $uri =404;
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fastcgi.conf;
                                #include pathinfo.conf;
                        }

                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }

                location ~ .*\.(js|css)?$
                        {
                                expires      12h;
                        }

                access_log off;
        }
12#
发表于 2015-5-22 17:30:13 | 只看该作者
__蛋丶碎 发表于 2015-5-22 16:44
server
        {
                listen 80;


第一个server_name中把主域名写上,不要写待转向的域名

然后原配置尾新开一个如下格式,把待转的域名写在server_name中,下面主域名
就是访问baidu.com会跳转到www.baidu.com去

  1. server {
  2.             listen       80;
  3.             server_name  baidu.com;
  4.             rewrite ^/(.*) http://www.baidu.com/$1 permanent;
  5. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-11-11 12:17 , Processed in 0.057131 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表