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..

2

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.