VPS侦探论坛

 找回密码
 注册
查看: 4845|回复: 1

请军哥帮忙看下,按照官方的方法操作301还是不会重定向?

[复制链接]
发表于 2015-11-18 15:21:28 | 显示全部楼层 |阅读模式

这个是添加虚拟主机的操作
[root@xxxxxxxxx]# lnmp vhost add
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              http://lnmp.org              |
+-------------------------------------------+
Please enter domain(example: www.lnmp.org): www.xxx.com
======================================
Your domain: www.xxx.com
======================================
Do you want to add more domain name? (y/n) y
Enter domain name(example: lnmp.org *.lnmp.org): xxx.com
domain list: xxx.com
Please enter the directory for the domain: www.xxx.com
Virtual Host Directory: /home/wwwroot/www.xxx.com
===========================
(Default directory: /home/wwwroot/www.xxx.com):
Allow Rewrite rule? (y/n)
===========================
y
Please enter the rewrite of programme:
wordpress,discuz,typecho,sablog,dabr rewrite was exist.
(Default rewrite: other):zsbry
===========================
You choose rewrite=zsbry
===========================
===========================
Allow access_log? (y/n)
===========================
n
======================================================
Create database and MySQL user with same name (y/n)
======================================================
n

Press any key to start create virtul host...

Create Virtul Host directory......
set permissions of Virtual Host directory......
Create Virtul Host ReWrite file......
Create rewirte file successful,You can add rewrite rule into /usr/local/nginx/conf/zsbry.conf.
Gracefully shutting down php-fpm . done
Starting php-fpm  done
Test Nginx configure file......
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

Restart Nginx......
================================================
Virtualhost infomation:
Your domain: www.xxx.com
Home Directory: /home/wwwroot/www.xxx.com
Rewrite: xxx
Enable log: no
Create database: no
Create ftp account: no
================================================


下面的是server的配置:
server
    {
        listen 80;
        #listen [::]:80;
        server_name www.xxx.com xxx.com;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/www.xxx.com;

        include zsbry.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;
    }


这个是按照http://lnmp.org/faq/lnmp-nginx-301-rewrite.html
server {
listen 80;
server_name lnmp.org;
return 301 http://www.lnmp.org$request_uri;
}


按这个操作不带www的不会301到带www的,是不是哪里配置错了啊?

请军哥帮忙看下,谢谢!!!
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2015-11-18 21:13:51 | 显示全部楼层

回复 1# 的帖子



肯定不行,不带www的要跳到带www的
www的虚拟主机肯定不能讲不带www的域名留在server_name里

server_name里面的域名必须是唯一的,重复是会报错的
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-25 08:12 , Processed in 0.025672 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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