Spent the better part of a day trying to get my head around this and finally need to ask for some help.
I have a bunch of folders which i want to make into subdomains. I have followed the tutorial below and have set up a wildcard redirect in my DNS in step 1 and edited my virualhost in step2. This seems to have gone to plan.
However i am unsure of the logic behind step 3. How does the code below allow me to display content from a folder in a subdomain? i cant figure out what logic i am supposed to try and code - i think i am clearly missing something obvious here.
$serverhost = explode('.',$_SERVER["HTTP_HOST"]);
$sub = $serverhost[0];
if ($sub = "www") {
$sub = "";
}
(text from tutorial)
OK, here's what's taking place. You insert this code in your main php file and what it does is check to see if the subdomain portion of the domain (ie: thishere.yourdomain.com) is www. If so, it just nulls $sub, otherwise, $sub will contain your subdomain keyword. Now, you can check if ($sub > "") and take appropriate action with your code if a subdomain exists, to display a page based on that value.
(tutorial link) http://www.wiredstudios.com/php-programming/setting-up-wildcard-dns-for-subdomains-on-cpanel.html
Thanks in advance.