嘟嘟社区

nginx配置301跳转到https和www的问题


这个配置有问题吗?会不会影响SEO权重,我这样配置了,百度站长工具里检测robots.txt提示301配置有误,但是打开都正常
打开不带www可以成功转到带www,打开不带http可以成功转到https
  1. #这是反代服务器的配置
  2. server {
  3.     listen 80;
  4.     server_name example.com www.example.com;
  5.     return 301 https://www.example.com$request_uri;
  6. }
  7. server {
  8.     listen 443;
  9.     server_name example.com;
  10.     ssl_certificate /data/ssl/www.example.com.crt;
  11.     ssl_certificate_key /data/ssl/www.example.com.key;
  12.     return 301 https://www.example.com$request_uri;
  13. }
  14.   
  15. server {
  16.     listen 443 ssl http2;
  17.    server_name www.example.com;
  18.     ssl_certificate /data/ssl/www.example.com.crt;
  19.     ssl_certificate_key /data/ssl/www.example.com.key;
  20.     ssl_session_timeout 10m;
  21.     location = / {
  22.         …
  23. }

复制代码

  1. #这是源站服务器的配置
  2. server {
  3.     listen 80;
  4.     server_name example.com www.example.com;
  5.     return 301 https://www.example.com$request_uri;
  6. }
  7. server {
  8.     listen 443;
  9.     server_name example.com;
  10.     ssl_certificate /usr/local/nginx/conf/ssl/www.example.com.crt;
  11.     ssl_certificate_key /usr/local/nginx/conf/ssl/www.example.com.key;
  12.     return 301 https://www.example.com$request_uri;
  13. }
  14. server {
  15.   #listen 80;
  16.   listen 443 ssl http2;
  17.   server_name www.example.com;
  18.   root /data/wwwroot/www.example.com;
  19.   index index.html index.htm index.php;
  20.   access_log /data/wwwlogs/www.example.com_nginx.log combined;
  21.   location = / {
  22.         …
  23.   
  24. }

复制代码

有看懂的提示下可以吗⠀