当前位置:论坛首页 > Linux面板 > 讨论

默认的www跳转和SLL后开启的定向都是302?怎么改301

发表在 Linux面板2017-6-5 14:19 [复制链接] 5 2537

默认的www跳转和SLL后开启的定向都是302?怎么改301permanent;    }??还是用重定向功能


使用道具 举报 只看该作者 回复
发表于 2017-6-5 14:34:30 | 显示全部楼层
加permanent 就可以了
使用道具 举报 回复 支持 反对
发表于 2017-6-5 14:49:57 | 显示全部楼层
官方推荐 return 301,rewrite 复杂而且性能差
使用道具 举报 回复 支持 反对
发表于 2017-6-5 15:03:42 | 显示全部楼层
his server block forces all visitors to use a secured (SSL/TLS) connection to your site.

server {
    listen 80;
    server_name www.domain.com;
    return 301 https://www.domain.com$request_uri;
}
Some other blogs about NGINX rewrite rules use an if test and the rewrite directive for this use case, like this:

# NOT RECOMMENDED
if ($scheme != "https") {
    rewrite ^ https://www.mydomain.com$uri permanent;
}
But this method takes extra processing because NGINX must both evaluate the if condition and process the regular expression in the rewrite directive.
使用道具 举报 回复 支持 反对
发表于 2017-6-6 14:30:27 | 显示全部楼层
所以是这样吗?

  1. server {
  2.     listen 80;
  3.     server_name www.pualab.com;
  4.     return 301 https://www.pualab.com$request_uri;
  5. }

  6. server {
  7.     listen 443 ssl;
  8.     server_name www.pualab.com pualab.com;
  9.     index index.php index.html index.htm default.php default.htm default.html;
  10.     root /www/wwwroot/pualab;
  11.     #error_page 404/404.html;
  12.     ssl_certificate    /etc/letsencrypt/live/pualab.com/fullchain.pem;
  13.     ssl_certificate_key    /etc/letsencrypt/live/pualab.com/privkey.pem;
  14.     error_page 497  https://$host$uri;
  15.     #error_page 404 /404.html;
  16.     error_page 502 /502.html;
  17.    
  18.     include enable-php-70.conf;
  19.     include /www/server/panel/vhost/rewrite/pualab.com.conf;
  20.     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  21.     {
  22.         expires      30d;
  23.         access_log off;
  24.     }
  25.     location ~ .*\.(js|css)?$
  26.     {
  27.         expires      12h;
  28.         access_log off;
  29.     }
  30.     access_log  /www/wwwlogs/pualab.com.log;
  31. }
复制代码


使用道具 举报 回复 支持 反对
发表于 2017-6-7 17:33:40 | 显示全部楼层
是吗是吗
使用道具 举报 回复
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

企业版年付运维跟进群

普通问题处理

论坛响应时间:72小时

问题处理方式:排队(仅解答)

工作时间:白班:9:00 - 18:00

紧急问题处理

论坛响应时间:10分钟

问题处理方式:1对1处理(优先)

工作时间:白班:9:00 - 18:00

工作时间:晚班:18:00 - 24:00

立即付费处理
快速回复 返回顶部 返回列表