全球主机交流论坛

标题: 有知道discuz 301重定向的么 [打印本页]

作者: 阳光淡蓝    时间: 2017-8-7 21:16
标题: 有知道discuz 301重定向的么
本帖最后由 阳光淡蓝 于 2017-8-7 22:35 编辑

LNMP,
discuz论坛(X3.4)怎么添加规则到.conf里呢
把不带www的跳转到 带www的
作者: qweasdzxc123    时间: 2017-8-7 21:28
和discuz屁关系没有。这是你的LNMP里的nginx做的事


  1. server {
  2.         listen 80;
  3.         listen [::]:80;

  4.         server_name example.com;
  5.         return 301 http://www.example.com$request_uri;
  6.         }
复制代码

作者: sky170    时间: 2017-8-7 21:41
楼上正解
作者: 阳光淡蓝    时间: 2017-8-7 22:10
qweasdzxc123 发表于 2017-8-7 21:28
和discuz屁关系没有。这是你的LNMP里的nginx做的事


请问是添加到最后么,重启LNMP时报错~

server
    {
        listen 80;
        #listen [::]:80;
        server_name namexxx.com www.namexxx.com;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/namexxx.com;

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

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

        include enable-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 off;
    }
       
        server {
        listen 80;
        listen [::]:80;

        server_name namexxx.com;
        return 301 http://www.namexxx.com$request_uri;
        }

作者: 62900015    时间: 2017-8-7 22:13
阳光淡蓝 发表于 2017-8-7 22:10
请问是添加到最后么,重启LNMP时报错~

server

开个新conf吧,要么就删除上面的server_name namexxx.com
作者: 阳光淡蓝    时间: 2017-8-7 22:18
62900015 发表于 2017-8-7 22:13
开个新conf吧,要么就删除上面的server_name namexxx.com

谢谢 重启不报错了。
但是访问站点 404 Not Found
作者: 哎呀    时间: 2017-8-7 22:18
阳光淡蓝 发表于 2017-8-7 22:10
请问是添加到最后么,重启LNMP时报错~

server


  新建个配置文件吧
作者: qweasdzxc123    时间: 2017-8-7 22:19
阳光淡蓝 发表于 2017-8-7 22:10
请问是添加到最后么,重启LNMP时报错~

server

试试这么搞

server {
        listen 80;
        listen [::]:80;

        server_name namexxx.com;
        return 301 http://www.namexxx.com$request_uri;
        }

server
    {
        listen 80;
        #listen [::]:80;
        server_name  www.namexxx.com;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/namexxx.com;
        …………
作者: chenvip5    时间: 2017-8-7 22:20
阳光淡蓝 发表于 2017-8-7 22:10
请问是添加到最后么,重启LNMP时报错~

server

只加这一个:
return 301 http://www.namexxx.com$request_uri;

加到你的:server_name namexxx.com www.namexxx.com;
下面一行




欢迎光临 全球主机交流论坛 (https://loc.1226.eu.org/) Powered by Discuz! X3.4