i know almost anything about sub-domains and dns records. i have heard about them and i know just the basics.
Actually, on my server, i do create the subdomain under plesk and then contact my hosting to create the right dns. and in 1-2 days the subdomain is reachable from everywhere (plesk can manage dns automatically, i know, but becose i dont know how does dns exactly works, i prefer to let my hoster handle them)
But.. when you do register on wordpress.com, posterous.com, etc, they create a subdomain like http://yourname.service_name.com that is ready in few seconds.. how?
I know this could be an question hardly to response because my ignorance i dont know how to formulate the question better -.-
Oh, if it can help, my environment must be linux (debian actually)
To do this in cPanel, look for the Subdomains tool in the Domains section: On the next screen, enter your desired subdomain in the Subdomain box and also select the parent domain via the Domain drop-down. There's no need to add a dot after the subdomain – just enter the text you want to use.
Creating a SubdomainEnter the desired subdomain. Choose one of your Domain Names from the drop-down list. Enter the Document Root (this is the folder that contains the website you want to show). We recommend that you use the same name for this folder as your subdomain.
After creating a subdomain via your DNS zone, it'll take up to 24 hours for the changes to take effect and the subdomain to work.
Most people achieve this by using a Wildcard DNS Record, this gives the appearence of creating subdomains instantly.
Once you've got a wildcard DNS setup like this:
*.example.com A 77.75.105.197
You need to tell Apache you want all sub domains to be caught by a virtual host, you can do this with ServerAlias:
ServerAlias *.example.com
In PHP you can then look at $_SERVER["SERVER_NAME"] to figure out what subdomain has been used to access the virtual host, you can then have subdomain specific code/content.
Here's the way pastebin.com does this:
That way, no DNS or Apache re-configuration is required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With