I want to provide new subdomains based on user request. I realized that there are two ways to do it:
- Using API of the DNS provider to register new CNAME records that point to pages within the website
- Making a wildcard
*.example.com
CNAME record that points to let's sayexample.com/subrouter
which determines the domain it is being called from and returns related documents (Or mass virtual hosts on apache).
Using method 1 feels a lot more natural as I'm adhering to the original design. But method 2 is flexible and gets the job done.
Server management is not my primary field so hopefully someone will clear this up for me. Is there any reason to chose one method over the other, lets say for performance or scalability or security? Which method is preferred by the pros?