阳光淡蓝 发表于 2017-8-7 21:16:20

有知道discuz 301重定向的么

本帖最后由 阳光淡蓝 于 2017-8-7 22:35 编辑

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

qweasdzxc123 发表于 2017-8-7 21:28:19

和discuz屁关系没有。这是你的LNMP里的nginx做的事


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

sky170 发表于 2017-8-7 21:41:14

楼上正解

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

62900015 发表于 2017-8-7 21:28:00


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

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

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

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


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

开个新conf吧,要么就删除上面的server_name namexxx.com
谢谢 重启不报错了。
但是访问站点 404 Not Found
lol.gif

哎呀 发表于 2017-8-7 22:10:00


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

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

server


008.gif
新建个配置文件吧

qweasdzxc123 发表于 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_namewww.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:13:00


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

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

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

加到你的:server_name namexxx.com www.namexxx.com;
下面一行
页: [1]
查看完整版本: 有知道discuz 301重定向的么