我在我的 nginx 服务器上设置了一个任意域配置 - 以减少打开新站点/域时所需的工作量。这个配置允许我简单地/usr/share/nginx/sites/用域/子域的名称创建一个文件夹,然后它就可以工作了。™
server {
# Catch all domains starting with only "www." and boot them to non "www." domain.
listen 80;
server_name ~^www\.(.*)$;
return 301 $scheme://$1$request_uri;
}
server {
# Catch all domains that do not start with "www."
listen 80;
server_name ~^(?!www\.).+;
client_max_body_size 20M;
# Send all requests to the appropriate host
root /usr/share/nginx/sites/$host;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ =404;
}
recursive_error_pages on;
error_page 400 /errorpages/error.php?e=400&u=$uri&h=$host&s=$scheme;
error_page 401 /errorpages/error.php?e=401&u=$uri&h=$host&s=$scheme; …Run Code Online (Sandbox Code Playgroud)