How do wordpress.com and other similar services instantly create a subdomain that is instantly available?

I know almost everything about subdomains and DNS records. I heard about them, and I know only the basics.

Actually, on my server I create a subdomain under plesk, and then contact my hosting service to create the correct DNS. and after 1-2 days, the subdomain is accessible everywhere (plesk can manage dns automatically, I know, but since I don’t know how dns works, I prefer my hoster to handle them)

But ... when you sign up for wordpress.com, posterous.com, etc., they create a subdomain, such as http://yourname.service_name.com , that is ready in a few seconds .. how?

I know that this can hardly be the answer, because my ignorance, I do not know how to better formulate the question.

Oh, if that can help, my environment should be linux (actually debian)

+6
subdomain dns hosting
source share
4 answers

Most people do this with the help of Wildcard DNS Record , this makes it possible to create subdomains instantly.


Once you configure the DNS lookup lookup as follows:

*.example.com A 77.75.105.197 

You need to tell Apache that you want all subdomains to be captured by the virtual host, you can do this with ServerAlias :

 ServerAlias *.example.com 

In PHP, you can look at $ _ SERVER ["SERVER_NAME"] to find out which subdomain was used to access the virtual host, then you can have specific code / content of the subdomain.

+19
source share

Here's the way pastebin.com does this:

  • wildcard DNS record indicates all subdomains on the IP web server
  • apache will send all requests to the "unknown" domains to the first virtual host - you will create code on this host that can do something interesting with the domain name (in PHP this is represented as $ _SERVER ['HTTP_HOST']

Therefore, no reconfiguration of DNS or Apache is required.

+2
source share

Wordpress does not create a subdomain, it cannot even create it, because it is part of the apaches virtual host configuration files.

The only way to make a subdomain is to create another virtual host record, add it to the DNS record, but it takes 24 hours to update the DNS servers. Plesk and other control panels can control this, but Wordpress cannot, because it is only a PHP script, which probably does not even have permission to execute this kind of material. In addition, you will not indicate where the configuration file is located, so Wordpress cannot know where the virtual host is located :)

Please tell us more about WordPress subdomains, where you create them, etc.

0
source share

Also note that you can through. Apache configured it so that it uses a regular expression for the host name, and through this installation root of the document it could be something like:

 /var/www/topleveldomain.com/subdomain/wwwroot 

This may create the illusion that changes have occurred in the configuration files and all this black magic, allowing mysubdomain.topleveldomain.com to become a new subdomain by simply creating a folder in the right place.

Also note that this happens with an asterisk alias in the DNS record.

However, I doubt that the way Wordpress does it, and as Paul Dixon mentions, is probably more likely.

0
source share

All Articles