请军哥帮忙看下,按照官方的方法操作301还是不会重定向?
这个是添加虚拟主机的操作:# 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-fpmdone
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_passunix:/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的,是不是哪里配置错了啊?
请军哥帮忙看下,谢谢!!!
回复 1# 的帖子
肯定不行,不带www的要跳到带www的www的虚拟主机肯定不能讲不带www的域名留在server_name里
server_name里面的域名必须是唯一的,重复是会报错的
页:
[1]