473,503 Members | 1,731 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Jul 17 '05 #1
6 2731
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

Jul 17 '05 #2
Hi Dani,

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

Thanks,
sharma

Jul 17 '05 #3
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

Jul 17 '05 #4
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/

Jul 17 '05 #5
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.

Jul 17 '05 #6
^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/

Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
626
by: seo | last post by:
Hi all, I have a site called www.Mydomain.com. I would like to offer free hoting to the people and offer a site with their username like this. www.Mydomain.com/user. I want user can upload...
3
1770
by: craigkenisston | last post by:
In an application I'm developing I will be using subdomains in the main website to hold some sections of the sites. There will be many serverside generated links that will point to this...
2
2734
by: craigkenisston | last post by:
Hi, I create a one day ticket in my authentication code like this : private void btnLogin_Click(object sender, System.EventArgs e) { string _userId = txtUserId.Text; string _password =...
4
2025
by: radiax | last post by:
Is there a way to associate or bind a subdomain to a tcp sockets under .net framework (vb.net / c#). I know ip address can be used when using sockets, but the problem is the ip address is shared...
1
5623
by: Hans Kesting | last post by:
Hi, Is it possible to share sessions between subdomains? Say: the user logs in at www.company.com, and is redirected to my.company.com. This is a different url for the same application. Can I...
8
4281
by: Kenny Lai | last post by:
hey, Is there a way to communicate between iframes on different subdomains? e.g. from one.dot.com to two.dot.com? there is a security access restriction passing javascript commands between...
1
3334
by: onequestion | last post by:
Hi friends.. Is it possible to find subdomains on a domain. Can someone help me? currently i'm using this code.. private static String GetSubDomain(URL url) ...
9
7777
by: Josh | last post by:
I run a Joomla website and am familiar with php in some but not all aspects. Currently I am trying to find some solutions related to session handling. Am I correct in saying that "login" is kept...
3
2949
by: Jonathan Wood | last post by:
Perhaps someone who understand Web hosting can offer some insight into this. I have several sites hosted at http://www.crystaltech.com. There were highly recommended and seem pretty good. But...
3
6657
by: akadeco | last post by:
Hi Could anyone give me some pointers on how to remove subdomains from a string? For example: If the string was bytes.com, it would stay bytes.com If it was subdomain.bytes.com, it would...
0
7087
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1514
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.