VPS侦探论坛

 找回密码
 注册
查看: 8571|回复: 5

nginx设置301重定向次数过多无法访问

[复制链接]
发表于 2018-5-31 09:47:42 | 显示全部楼层 |阅读模式

nginx设置301 重定向后网页显示 重定向次数过多无法访问,请问应该怎么修改?

server {
listen 80;
server_name aaa.com  www.aaa.com  bbb.com www.bbb.com;
return 301 http://www.bbb.org$request_uri;
}

代码就是上面的这种。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2018-5-31 09:48:06 | 显示全部楼层


我的环境是lnmpa
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2018-5-31 10:05:51 | 显示全部楼层

详细的代码


server
    {
        listen 80;
        #listen [::]:80;
        server_name www.jbyan.com jbyan.com zshypt.com www.zshypt.com;
        #return 301 http://www.zshypt.com$request_uri;

         index index.html index.htm index.php default.html default.htm default.php;
        root  /mnt/home/www/www.jbyan.com;

        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include proxy-pass-php.conf;

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

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

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/www.jbyan.com.log;
     }
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2018-5-31 12:23:59 | 显示全部楼层

回复 3# 的帖子




本身就很冲突吧,你看看301跳转....到底是谁跳转到谁
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2018-5-31 13:34:54 | 显示全部楼层

www.jbyan.com jbyan.com zshypt.com 全部跳转到www.zshypt.com

军哥运维代购:http://shop63846532.taobao.com/

发表于 2018-5-31 20:46:21 | 显示全部楼层

1楼代码必定301重定向多次,没有实际网站只有这几个域名一个虚拟主机肯定一直在301中

你得说明好你要设置的效果,如果是其他域名都跳到 www.zshypt.com 上,把www.zshypt.com这个虚拟主机上的其他域名都删除掉只保留www.zshypt.com
要设置301的虚拟主机server_name上除www.zshypt.com的域名都加上,重启nginx
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-24 03:28 , Processed in 0.034691 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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