English is not my native language, please accept my apologies for any language issues.
I want a configuration with automatic root, regardless of domain, look like this (using nginx):
root /var/www/${http_host}/public
But I want the root domain and the "www" to point to the same directory, but without the "www":
Example:
"www.mysite.com" and "mysite.com"
root /var/www/mysite.com/public
But "blog.mysite.com"
root /var/www/blog.mysite.com/public
That is, only the "www" should point to the directory that does not have "www" in the name.
Yes I saw that there are other similar questions (like this one), but I had difficulty removing the "www". Excuse me!
I will not use such a generic server_name, but this should work even with:
server_name ~.+$;
But also so:
listen 443 ssl http2;
server_name ~ ^((www|blog|account|bbs)\.)?mysite.com$;
root /var/www/${http_host}/public
ssl_certificate /ssl/${http_host}/{http_host}.pem
ssl_certificate_key /ss/${http_host}/{http_host}.key
NOTE: It should work with from the ssl certificate path.