Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Wildcard subdomains based on subdirectories

$
0
0
Hello All-

I have nginx installed on a VPS I use to develop websites. We develop anywhere between 10 and 20 sites at a time, each of which we do on a subdomain. Currently, I am setting up server blocks for each site, which gets repetitive and inefficient. My goal is to setup wildcard subdomains for example.com based on whatever is in the example.com subfolder for example:

If I create a folder in /var/www/example.com/ called sub1, then I would like nginx to automatically direct visitors who visit sub1.example.com to the root of that folder.

I would like this to happen for any future subfolders I create, in that the server_name would automatically be subfoldername.example.com

Does this make sense?

I have my DNS setup for wildcard domains, so I just need Nginx to take them to the correct area.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>