将重定向与服务文件相结合

时间:2017-05-11 18:05:50

标签: redirect nginx

我有几个服务器块彼此不能很好用,我想从.well-known/文件夹提供文件,但是当它们不是来自{https时,也会重定向到.well-known/ 1}}文件夹

如何制作一个重定向的服务器块,还可以提供一些文件?

/ BLOCK1启用位点-

server {
  listen 80 default_server;
  listen [::]:80 default_server;
  root /var/www/html;
  index index.html;
  server_name _;

  location ~ /.well-known {
    allow all;
  }

  location / {
    try_files $uri $uri/ =404;
  }
}

/ BLOCK2启用位点-

server {
  listen 80;
  listen [::]:80;
  server_name www.example.com;
  return 301 https://example.com$request_uri;
}
server {
  listen 80;
  listen [::]:80;
  server_name example.com www.example.com cdn.example.com subdomain.example.com;
  return 301 https://$host$request_uri;
}

0 个答案:

没有答案