Nginx 不同二级域名访问一直出现301重定向

Nginx配置了多个二级域名  全部都是https请求

一台机器上有一个项目配置 2 个二级域名都指向了这一个目录

例如:

域名一: https://www.website.com ,
域名二: https://admin.website.com ,

直接输入 https://admin.website.com 会自动重定向到 https://www.website.com  这个是什么原因?
 

当前Nginx配置如下

server {
  listen 80;
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  ssl_certificate /usr/local/nginx/conf/ssl/www.website.com.crt;
  ssl_certificate_key /usr/local/nginx/conf/ssl/www.website.com.key;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
  ssl_prefer_server_ciphers on;
  ssl_session_timeout 10m;
  ssl_session_cache builtin:1000 shared:SSL:10m;
  ssl_buffer_size 1400;
  add_header Strict-Transport-Security max-age=15768000;
  ssl_stapling on;
  ssl_stapling_verify on;
  server_name www.website.com admin.website.com;
  access_log /data/wwwlogs/www.website.com_nginx.log combined;
  index index.html index.htm index.php;
  root /data/wwwroot/www.website.com/public;
  if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
  if ($host != www.website.com) {  return 301 $scheme://$host$request_uri;  }
  include /usr/local/nginx/conf/rewrite/other.conf;
  #error_page 404 /404.html;
  #error_page 502 /502.html;
  location / {
    if (!-e $request_filename) {
      rewrite  ^/(.*)$  /index.php/$1  last;
      break;
    }
  }

  location ~ \.php
  {
    #fastcgi_pass remote_php_ip:9000;
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
    set $real_script_name $fastcgi_script_name;
    if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
            set $real_script_name $1;
            set $path_info $2;
    }
    fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
    fastcgi_param SCRIPT_NAME $real_script_name;
    fastcgi_param PATH_INFO $path_info;
  }

  location ~ /\.ht {
    deny all;
  }
}
 

上一篇:Docker 简单发布dotnet core项目


下一篇:PHP 对接 饿了么开放平台 接单