Click to See Complete Forum and Search --> : creating dyanamic sub domain using php


haroon373
09-19-2007, 01:01 AM
Hi,

i just want to copy the blogspot.com feature in my open source blog cms
that every user have its own sub domain name on blogspot.com with his username or his desired name. eg {username.blogspot.com}

i dont want to create folder on server
i dont want to create actuall sub domain on server

i just want the behavior of the blogspot.com

any body please help me out
how to do this

i dont have enogh knowlegde about php, apache, .htaccess

thnx in advance

michael879
09-19-2007, 12:47 PM
I could be wrong but I dont think its possible. I think you need to actually setup a subdomain, or go into the dns server.

haroon373
09-19-2007, 10:56 PM
I could be wrong but I dont think its possible. I think you need to actually setup a subdomain, or go into the dns server.

You actally didn't read my post
i said as blogspot.com doing

michael879
09-21-2007, 11:31 AM
I read your post, and what blogspot is doing seems to be what everyone else is doing. Maybe theyre doing some of it with php (like creating directories for the users) but Im sure theres more to it

Sheldon
09-21-2007, 12:52 PM
It is easy, If your DNS is set up with a wildcard to point to your main site.

Here is a start, all you have to set is the domain var, and set this to your domain name with out the .com


<?php

$domain = "apple"; // eg: apple.com
$host = $_SERVER['HTTP_HOST'];
$vars = explode(".", $host);
if(($vars['0'] != "www") or ($vars['0'] != $domain)){
if(file_exists("/{$var['0']}/")){
header("Location: /{$var['0']}/");
}
}
echo("The Sub Domain is not a valid user, so here is the main site.");

?>