我想将所有子域名重定向到我的主域名,但目前尚未生效。以下是我的做法:
server {
listen [::]:80;
server_name *.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
listen [::]:443;
server_name example.com;
ssl on;
ssl_certificate /etc/ssl/certs/example.com.crt;
ssl_certificate_key /etc/ssl/private/example.com.key;
#enables all versions of TLS, but not SSLv2 or 3 which are weak and now deprecated.
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#Disables all weak ciphers
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECD$
ssl_prefer_server_ciphers on;
root /var/www/html;
index index.html;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
}
然而,当我输入例如www.example.com
时,它会重定向到https://www.example.com
,如何将所有子域名重定向到https://example.com
?
fastcgi_script_name
是 FastCGI 协议中的一个环境变量,它表示正在处理的脚本文件的路径。 - 9769953