Jump to content
xisto Community
Sign in to follow this  
dragonfang00

How To Create Subdomain Using Php? creating subdomain automatically after signing up

Recommended Posts

Hi everyone,i really don't know if this is the right place, so please just move this to the right category..now here's my problem:I want to create a website for my high school batch graduated last 2004 so we can interact to our old friends. but i want it to be like ning.com, myspace.com or friendster.com that you can add your own layout (css) for your profile and putting the new user in it's own profile page (using a subdomain for their own profile page)can anyone tell me how to automatically create the subdomain and putting the CSS and other files in the subdomain automatically? thanks in advance..

Share this post


Link to post
Share on other sites

I dont think there is a way to add the subdomain using PHP, however it may be possible to set up your host to redirect subdomains so that if i went to blah.yourhost.com it would redirect to: yourhost.com/blah even though the "blah" subdomain doesnt actually exist.... if that makes sense?

Share this post


Link to post
Share on other sites

I don't think there is a way, unless you have specific software for things like reseller hosting on your host management.On thing to do, would be to set up your 404 error page, so that it breaks down the URL, and checks if there is a subdomain on it, then checks if that is a user name, if so, it redirects to that users page(s)

Share this post


Link to post
Share on other sites

I want to create a website for my high school batch graduated last 2004 so we can interact to our old friends. but i want it to be like ning.com, myspace.com or friendster.com that you can add your own layout (css) for your profile and putting the new user in it's own profile page (using a subdomain for their own profile page)
can anyone tell me how to automatically create the subdomain and putting the CSS and other files in the subdomain automatically? thanks in advance..


basically you want to automatically create pages when people sign up. you don't need to automatically create sub domains to do this though. you do however need to automatically create directories for each individual user signup. is there a reason why you would want to create individual subdomains rather than individual directories?

now to answer your question, i believe there are simple scripts floating around here and there for $100 or so which will do what you want. if you need more advanced programming, i suggest hire a programmer. other than that, i hope someone someone can answer your question better because i would love to look at a script that does this.

Share this post


Link to post
Share on other sites

What you can do is add a new wildcard subdomain. You can do this with DNS management like the tutorial I linked to below tells you to, but if you do not have access to your DNS management you can just add a new subdomain in your cpanel. To make it wildcard just add *.yourdomain.com. After doing this give the server some time to update, but if you did it right any subdomain you go to should return the same output as your root domain name (i.e. your index page).

After you add *.yourdomain.com create the .htaccess file below, and then all you have to do is have php make new directories in your root folder with the dynamic subdomain you want.

This code should be placed in the htaccess file in the root of your domain, i.e. domain.com/.htaccess

<IfModule mod_rewrite.c>   Options +FollowSymLinks   Options +Indexes   RewriteEngine On   RewriteBase /   RewriteCond %{HTTP_HOST} !domain.com; [NC]   RewriteCond %{HTTP_HOST} ^(http://forums.xisto.com/no_longer_exists/ [NC]   RewriteRule (.*) %2/$1 [L]</IfModule>[/quote]

Source
Edited by galexcd (see edit history)

Share this post


Link to post
Share on other sites

basically you want to automatically create pages when people sign up. you don't need to automatically create sub domains to do this though. you do however need to automatically create directories for each individual user signup. is there a reason why you would want to create individual subdomains rather than individual directories?
now to answer your question, i believe there are simple scripts floating around here and there for $100 or so which will do what you want. if you need more advanced programming, i suggest hire a programmer. other than that, i hope someone someone can answer your question better because i would love to look at a script that does this.


well, i can do this but I don't know the code.. I don't really need to hire a programmer because I can actually do it.. the thing is I don't know the code for the automatic creation of subdomain/directories and putting/creating the files in that directory..

What you can do is add a new wildcard subdomain. You can do this with DNS management like the tutorial I linked to below tells you to, but if you do not have access to your DNS management you can just add a new subdomain in your cpanel. To make it wildcard just add *.yourdomain.com. After doing this give the server some time to update, but if you did it right any subdomain you go to should return the same output as your root domain name (i.e. your index page).
After you add *.yourdomain.com create the .htaccess file below, and then all you have to do is have php make new directories in your root folder with the dynamic subdomain you want.
Source


thanks.. I'll try it on my host and if I can do it i'll use it on my project.. XD thanks a lot..

Share this post


Link to post
Share on other sites

Hi everyone,
i really don't know if this is the right place, so please just move this to the right category..

now here's my problem:

I want to create a website for my high school batch graduated last 2004 so we can interact to our old friends. but i want it to be like ning.com, myspace.com or friendster.com that you can add your own layout (css) for your profile and putting the new user in it's own profile page (using a subdomain for their own profile page)

can anyone tell me how to automatically create the subdomain and putting the CSS and other files in the subdomain automatically? thanks in advance..




There is a way you could do it. you could write a script that uses the Exec command to create a directory and then have the script generator the profile template files in that directory. you would probably need to include an .HTACCESS file just in case allowing all access to that directory. something like this
<?PHP$uid = $_GET['username]; exec(escapeshellcmd("mkdir $uid"), $out);include('profile_maker.php'); <---- script to generator to profile template etc.?>
it would take more a lot more then this, this is just an example of how it could be done.
you would then have to have the profile_maker generate the profile template files to the directory $out
would be easier to use profiles.php?uid=30403040304 <--- userid number

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.