0

Example:

http://example.com

and

http://www.example.com

are linked to the path (it's their root)

/var/www

I want that any other subdomain (like test.example.com or 1234.example.com) is linked automatically (without defining the subdomain as server_name in a conf-file) to /var/www/pathforanysub for example:

test.example.com

and

1234.example.com

have the same root

/var/www/pathforanysub

I'm very new to nginx and it would be quite cool if someone could help me..

1 Answer 1

2

You have to create a new server block, with a wildcard server_name.

server {
    server_name *.example.com;
    root /var/www/whatever;
2
  • This isn't working. Instead of /var/www/pathforanysub the standard-path /var/www is loaded.
    – featMarcel
    Jan 3, 2016 at 12:25
  • Then check your config for typos, and make sure you actually did restart nginx. Jan 3, 2016 at 14:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .