creating subdomains using php

This is a discussion on creating subdomains using php within the PHP Language forums, part of the PHP Programming Forums category; Hi all, I have a site called www.example.com. I would like to offer free hoting to the people ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-12-2005
sharma
 
Posts: n/a
Default creating subdomains using php

Hi all,

I have a site called www.example.com. I would like to offer free hoting
to the people and offer a site with their username like this.
www.username.example.com. Please can any one here tell me how to
accomplish this using php ?

Thanks,
sharma

Reply With Quote
  #2 (permalink)  
Old 01-12-2005
Dani CS
 
Posts: n/a
Default Re: creating subdomains using php

sharma wrote:
> Hi all,
>
> I have a site called www.example.com. I would like to offer free hoting
> to the people and offer a site with their username like this.
> www.username.example.com. Please can any one here tell me how to
> accomplish this using php ?


This is not done with PHP.

Apache can handle dynamic virtual hosts, which is what you want. Please
check <http://httpd.apache.org/docs/vhosts/>.


>
> Thanks,
> sharma
>

Reply With Quote
  #3 (permalink)  
Old 01-12-2005
sharma
 
Posts: n/a
Default Re: creating subdomains using php

Hi Dani,

When a user submits the registration form , how did this virtual host
create from php script? Any idea...

Thanks,
sharma

Reply With Quote
  #4 (permalink)  
Old 01-12-2005
Dani CS
 
Posts: n/a
Default Re: creating subdomains using php

sharma wrote:
> Hi Dani,
>
> When a user submits the registration form , how did this virtual host
> create from php script? Any idea...


Read the documentation about mass dynamic virtual hosts and then figure
it out.

It involves creating a directory (php: mkdir()) and probably assigning
it the proper permissions (php: chmod()). Good luck!

Taken from the Apache docs:

<quote src="http://httpd.apache.org/docs/vhosts/mass.html#motivation">
2. Adding virtual hosts is simply a matter of creating the
appropriate directories in the filesystem and entries in the DNS - you
don't need to reconfigure or restart Apache.
</quote>


About the DNS thing, I can't help you. Depending on your case it might
even be unnecessary. Anyways, this is not the best newsgroup for that
matter.

>
> Thanks,
> sharma
>

Reply With Quote
  #5 (permalink)  
Old 01-12-2005
R. Rajesh Jeba Anbiah
 
Posts: n/a
Default Re: creating subdomains using php

sharma wrote:
> Hi Dani,
>
> When a user submits the registration form , how did this virtual host
> create from php script? Any idea...


Usually, they won't. There are lots of way to do it with virtual
host directive. Most simplest thing is to use ServerAlias...

<VirtualHost *>
....
ServerName example.com
ServerAlias *.example.com
....
</VirtualHost>

Now, anything like a.example.com or b.example.com will be served
with example.com's content.

Now, you actually want to serve different pages for a.example.com
and b.example.com. So, you have to see what is the requested subdomain
(whether it's "a" or "b"). In PHP, you can see it through $_SERVER
variables or may again use mod_rewrite to send the subdomain request to
a php file as query string like index.php?subdomain=%1 or so.

So, you basically have only one index.php file, but will have
different requests coming (via subdomain). index.php can serve
different pages depending upon the request.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Reply With Quote
  #6 (permalink)  
Old 01-12-2005
^demon
 
Posts: n/a
Default Re: creating subdomains using php

You would need to find what the required text in httpd.conf is, and
then have your script write to httpd.conf the required value. Seems
quite insecure though.

Reply With Quote
  #7 (permalink)  
Old 01-12-2005
R. Rajesh Jeba Anbiah
 
Posts: n/a
Default Re: creating subdomains using php

^demon wrote:
> You would need to find what the required text in httpd.conf is, and
> then have your script write to httpd.conf the required value. Seems
> quite insecure though.


Sorry, I don't understand what are you talking about. Could you be
more specific?

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:09 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0