07-11-2007, 07:15 PM
Today I was browsing ebay.com and I come to know that for every main category they created a sub domain, like there is a category watches and the URL for watches will be like watches.ebay.com etc.
Now I wanted to know what whey is to so that I can create a sub domain using PHP script.
basically the thing i want to copy ebay model and that's why i am looking for making these sub domains.
if any one has any good suggestion also suggest me on it and you know they [ebay] people has a huge database can mysql bear this thing or not?
07-11-2007, 07:25 PM
I dont know too much about php, but im pretty sure you cant create sub-domains. Usually you make sub-domains through your host, and most of the time you can only create them on paid hosts.
07-11-2007, 07:30 PM
You can create them via php, but it's much easier to use mod-rewrite to create 'fake' subdomains. I'm sure that's what ebay does, can't imagine them having hundreds of subdomains all of which contains the same things
07-12-2007, 05:32 AM
how to create " fake " domain then? lol
07-12-2007, 07:23 AM
lol, Google ftw
I have had to create dynamic subdomains based on values in a mysql db for some projects at work and its not as hard as you would think.
What I have is wildcard DNS, apache virtual hosts, and php working together to pull it off.
Widlcard DNS will send all request to my server where I have normally have 3 virtual host for every site.
one is mydomain.tld
another is admin.mydomain.tld
the last is *.mydomain.tld
it needs to go in this order so that real subdomains don't get served by *.mydomain.tld
Once there, I use modrewrite (only on *.mydomain.tld) to set an ENVIRONMENT variable, which is available to php, for the subdomain.
I can then show dynamic content for the subdomain.
It can act as username, company name, project, or some other unique identifier, which is stored in MySQL.
07-16-2007, 03:25 AM
Dynamic subdomains... like on imeem and such...
$site_url = strtolower($_SERVER['HTTP_HOST']);
if(strpos($site_url,':')) $site_url = substr($site_url,0,strpos($site_url,':'));
if ($site_url == 'example.org') header('Location: http://www.example.org');
elseif ($site_url!= 'www.example.org')
if(strpos($site_url,'example.org')) $host_length = strlen('example.org');
$user = substr($site_url,0,strlen($site_url)-$host_length-1);