找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 80|回复: 8

有知道discuz 301重定向的么

[复制链接]

617

主题

5007

回帖

1万

积分

论坛元老

积分
12045
发表于 2017-8-7 21:16:20 | 显示全部楼层 |阅读模式
本帖最后由 阳光淡蓝 于 2017-8-7 22:35 编辑

LNMP,
discuz论坛(X3.4)怎么添加规则到.conf里呢
把不带www的跳转到 带www的
回复

使用道具 举报

756

主题

7520

回帖

1万

积分

论坛元老

积分
17390
发表于 2017-8-7 21:28:19 | 显示全部楼层
和discuz屁关系没有。这是你的LNMP里的nginx做的事


[ol]
  • server {
  •         listen 80;
  •         listen [::]:80;
  •         server_name example.com;
  •         return 301 http://www.example.com$request_uri;
  •         }[/ol]复制代码
  • 回复

    使用道具 举报

    42

    主题

    1695

    回帖

    3590

    积分

    论坛元老

    积分
    3590
    发表于 2017-8-7 21:41:14 | 显示全部楼层
    楼上正解
    回复

    使用道具 举报

    617

    主题

    5007

    回帖

    1万

    积分

    论坛元老

    积分
    12045
     楼主| 发表于 2017-8-7 22:10:56 | 显示全部楼层

    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;
            }
    回复

    使用道具 举报

    485

    主题

    5467

    回帖

    1万

    积分

    论坛元老

    积分
    12547
    发表于 2017-8-7 21:28:00 | 显示全部楼层

    阳光淡蓝 发表于 2017-8-7 22:10

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

    server

    开个新conf吧,要么就删除上面的server_name namexxx.com
    回复

    使用道具 举报

    617

    主题

    5007

    回帖

    1万

    积分

    论坛元老

    积分
    12045
     楼主| 发表于 2017-8-7 22:13:29 | 显示全部楼层

    62900015 发表于 2017-8-7 22:13

    开个新conf吧,要么就删除上面的server_name namexxx.com

    谢谢 重启不报错了。
    但是访问站点 404 Not Found

    回复

    使用道具 举报

    120

    主题

    1208

    回帖

    2896

    积分

    金牌会员

    积分
    2896
    发表于 2017-8-7 22:10:00 | 显示全部楼层

    阳光淡蓝 发表于 2017-8-7 22:10

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

    server




      新建个配置文件吧
    回复

    使用道具 举报

    756

    主题

    7520

    回帖

    1万

    积分

    论坛元老

    积分
    17390
    发表于 2017-8-7 22:18:00 | 显示全部楼层

    阳光淡蓝 发表于 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;
            …………
    回复

    使用道具 举报

    9

    主题

    583

    回帖

    1267

    积分

    金牌会员

    积分
    1267
    发表于 2017-8-7 22:13:00 | 显示全部楼层

    阳光淡蓝 发表于 2017-8-7 22:10

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

    server

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

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

    使用道具 举报

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

    本版积分规则

    Archiver|手机版|小黑屋|Discuz! X

    GMT+8, 2025-4-21 16:29 , Processed in 0.019747 second(s), 3 queries , Gzip On, Redis On.

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

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