How do you assign a subdomain to a variable in pHp?
Basically, I want to emulate what they did on wishesyouamerrychristmas.com where they have a movie that imports the variable name of the subdomain.
So, if someone typed in subd.domain.com, the movie would say, "Hello, subd. Welcome to domain."
I can handle all of the movie importation once I can assign the subdomain to a variable. Any ideas?
Greg K posted this at 08:37 — 16th March 2005.
He has: 2,145 posts
Joined: Nov 2003
Well, in your example, $_SERVER['SERVER_NAME'] will be set to subd.domain.com so you could do something like:
<?php
$mainDomain = 'domain.com';
$subDomain = substr($_SERVER['SERVER_NAME'],0,(0-strlen($mainDomain)-1));
echo \"Main Domain = $mainDomain \n\";
echo \"Sub Domain = $subDomain \n\";
?>
Now as to how to set up the server so all subdomains dns settings send you to your main domain, I'm not sure about.
-Greg
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.