| |
|
Welcome to KnowledgeSutra - Dear Guest | |
How To Create Subdomain Using Php?
Started by dragonfang00, Nov 04 2008 06:40 AM
6 replies to this topic
#1
Posted 04 November 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..
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..
#2
Posted 04 November 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?
#3
Posted 04 November 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)
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)
#4
Posted 04 November 2008 - 04:55 PM
dragonfang00, on Nov 4 2008, 01:40 AM, said:
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..
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.
#5
Posted 04 November 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.
Source
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
<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
Edited by galexcd, 04 November 2008 - 05:11 PM.
#6
Posted 05 November 2008 - 07:40 PM
anwiii, on Nov 5 2008, 12:55 AM, said:
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.
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..
galexcd, on Nov 5 2008, 01:09 AM, said:
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
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..
#7
Posted 16 February 2009 - 10:08 AM
dragonfang00, on Nov 4 2008, 06:40 AM, said:
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..
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
Reply to this topic

1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users















