已经自行解决:lnmp1.3版本的301重定向问题
安装军哥的lnmp1.3版本。想设置一下301重定向。。xxx.com 到www.xxx.com vi /usr/local/nginx/conf/vhost/自己的域名.conf一, server{
listen 80;
server_name www.xxxx.com xxxx.com;if ($host = 'xxxx.com' ) { rewrite ^/(.*)$ http://www.xxxx.com/$1 permanent; }
}
在server段域名下设置:
if ($host = 'xxxx.com' ) { rewrite ^/(.*)$ http://www.xxxx.com/$1 permanent; }
二,省略www.lnmp.org虚拟主机server配置
server {
listen 80;
server_name lnmp.org;
return 301 http://www.lnmp.org$request_uri;
}三,将/usr/local/nginx/conf/vhost/youdomain.com.conf中修改如下Server{
Server_name youdomain.com www.youdomain.com; //删除youdomain.com
. . .
}
Server{
Server_name youdomain.com;
rewrite ^(.*) http://www.youdomain.com$1 permanent;
}
但是没有动静。是什么原因呢 也重启了lnmp restart..
server {
server_name xxxx.com;
return 301 $scheme://www.xxxx.com$request_uri;
} 用这个解决了
[ 本帖最后由 sucrezhou 于 2016-6-20 13:35 编辑 ] 两个server_name域名重复肯定就会冲突
页:
[1]