IPB

Welcome Guest ( Log In | Register )



Tags
This content has not been tagged yet
 
Reply to this topicStart new topic

How To Create Subdomain Using Php?

, creating subdomain automatically after signing up


dragonfang00
no avatar
Member [Level 1]
****
Group: Members
Posts: 73
Joined: 3-November 08
From: Philippines
Member No.: 71,312
myCENT:94.95



Post #1 post Nov 4 2008, 06:40 AM
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..
Go to the top of the page
+Quote Post
shadowx
no avatar
Look around, what do you see? Incorrect.
***********
Group: [HOSTED]
Posts: 1,324
Joined: 12-April 06
From: Essex, UK
Member No.: 21,719
Spam Patrol
myCENT:32.70



Post #2 post Nov 4 2008, 01:11 PM
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?

Go to the top of the page
+Quote Post
minimcmonkey
no avatar
Super Member
*********
Group: [HOSTED]
Posts: 407
Joined: 19-June 08
From: United Kingdom - Cornwall!!!!!
Member No.: 63,876
myCENT:80.60



Post #3 post Nov 4 2008, 04:53 PM
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)
Go to the top of the page
+Quote Post
anwiii
no avatar
Privileged Member
*********
Group: [HOSTED]
Posts: 920
Joined: 5-March 06
From: Warsaw, MO
Member No.: 19,564
myCENT:74.40



Post #4 post Nov 4 2008, 04:55 PM
QUOTE(dragonfang00 @ Nov 4 2008, 01:40 AM) [snapback]415982[/snapback]
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.
Go to the top of the page
+Quote Post
galexcd
no avatar
Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software.
***********
Group: [MODERATOR]
Posts: 1,316
Joined: 25-September 05
From: Los Angeles, California
Member No.: 12,251
myCENT:59.43



Post #5 post Nov 4 2008, 05:09 PM
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.
QUOTE
This code should be placed in the htaccess file in the root of your domain, i.e. domain.com/.htaccess

CODE
<IfModule mod_rewrite.c>
   Options +FollowSymLinks
   Options +Indexes
   RewriteEngine On
   RewriteBase /
   RewriteCond %{HTTP_HOST} !www.domain.com$ [NC]
   RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).domain.com [NC]
   RewriteRule (.*) %2/$1 [L]
</IfModule>
[/quote]


Source

This post has been edited by galexcd: Nov 4 2008, 05:11 PM
Go to the top of the page
+Quote Post
dragonfang00
no avatar
Member [Level 1]
****
Group: Members
Posts: 73
Joined: 3-November 08
From: Philippines
Member No.: 71,312
myCENT:94.95



Post #6 post Nov 5 2008, 07:40 PM
QUOTE(anwiii @ Nov 5 2008, 12:55 AM) [snapback]416099[/snapback]
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..

QUOTE(galexcd @ Nov 5 2008, 01:09 AM) [snapback]416102[/snapback]
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..
Go to the top of the page
+Quote Post
nitestryker
no avatar
Newbie
*
Group: Members
Posts: 1
Joined: 16-February 09
Member No.: 77,048



Post #7 post Feb 16 2009, 10:08 AM
QUOTE (dragonfang00 @ Nov 4 2008, 06:40 AM) *
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
CODE
<?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
Go to the top of the page
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   2 gamefreaksl 4,441 20th July 2004 - 11:51 PM
Last post by: gamefreaksl
No New Posts   1 CodeName_88 3,099 30th July 2004 - 04:10 PM
Last post by: OpaQue
No New Posts   1 -sswebmasters- 3,744 30th July 2004 - 08:43 AM
Last post by: OpaQue
No New Posts 6 itasor 4,214 2nd August 2004 - 05:49 PM
Last post by: OpaQue
No New Posts   1 Be_Legend 5,169 30th July 2004 - 08:49 AM
Last post by: OpaQue
No New Posts   1 dontmaimyourself 3,397 31st July 2004 - 03:04 PM
Last post by: OpaQue
No New Posts   3 Angelexi 2,637 2nd August 2004 - 10:51 AM
Last post by: OpaQue
No New Posts   1 cti 3,657 31st July 2004 - 03:08 PM
Last post by: OpaQue
No New Posts   1 nightdagger 3,147 31st July 2004 - 03:20 PM
Last post by: OpaQue
No New Posts   3 -sever- 2,370 31st July 2004 - 08:33 PM
Last post by: OpaQue
No New Posts 2 priestess_isis 2,577 31st July 2004 - 08:32 PM
Last post by: OpaQue
No New Posts 1 R3D 3,975 1st August 2004 - 10:22 AM
Last post by: OpaQue
No New Posts   1 The Devils Playpen 2,779 2nd August 2004 - 06:03 PM
Last post by: OpaQue
No New Posts   2 stevey 2,702 2nd August 2004 - 04:32 PM
Last post by: OpaQue
No New Posts   1 jailbox 3,099 4th August 2004 - 07:51 AM
Last post by: OpaQue


 



RSS Open Discussion Time is now: 8th November 2009 - 04:37 PM

Web Hosting Powered by ComputingHost.com.