VPS侦探论坛

 找回密码
 注册
查看: 3659|回复: 4

lnmp1.4 301重定向错误

[复制链接]
发表于 2017-2-5 22:38:23 | 显示全部楼层 |阅读模式

遇到个奇怪的错误,创建虚拟主机后,搭建的是discuz。没有配置过301,但状态检测显示却为301,然后按照教程设置301重定向(return 301 http://www.heima3d.com$request_uri; )后网站就打不开了。chrome提示:www.heima3d.com 将您重定向的次数过多。
再试了一下,另外创建一个虚拟主机,只放一个静态页面,配置301后同样的结果


求救军哥,怎么解决...
  1. server
  2.     {
  3.         listen 80;
  4.         #listen [::]:80;
  5.         server_name www.heima3d.com heima3d.com;
  6.         return 301 http://www.heima3d.com$request_uri;
  7.         index index.html index.htm index.php default.html default.htm default.php;
  8.         root  /home/wwwroot/www.heima3d.com;

  9.         include discuz.conf;
  10.         #error_page   404   /404.html;

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

  13.         include enable-php.conf;

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

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

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

  25.         location ~ /\.
  26.         {
  27.             deny all;
  28.         }

  29.         access_log  /home/wwwlogs/www.heima3d.com.log;
  30.     }
复制代码

[ 本帖最后由 bbskgm 于 2017-2-5 23:44 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2017-2-6 09:51:11 | 显示全部楼层


很明显的错误,不带www的要单独写出来,具体看教程:https://lnmp.org/faq/lnmp-nginx-301-rewrite.html
有些网站程序上就自带301
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2017-2-6 10:16:23 | 显示全部楼层

这样啊,,谢谢,折腾死我了。。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2017-2-7 14:28:57 | 显示全部楼层



我是这样写的
server {
            listen 80;
            #listen [::]:80 default_server ipv6only=on;
            server_name itbiji.net www.itbiji.net;
            if ($host != ('www.itbiji.net')){
                            rewrite ^(.*) http://www.itbiji.net$1 permanent;
                                #非法域名跳转
            }

[ 本帖最后由 ITBIJI 于 2017-2-7 14:30 编辑 ]
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2017-2-7 17:10:48 | 显示全部楼层

回复 4# 的帖子


if判断效率低点

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

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-27 21:24 , Processed in 0.026320 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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