473,657 Members | 2,348 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 2748
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.or g/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.or g/docs/vhosts/mass.html#motiv ation">
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?subdo main=%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 only one Index.html only. Please can any one here tell me how to accomplish this using php ?
3
1777
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 subdomains. I already have subdomains in a preproduction server and it works fine then, but how do I do that here in my development machine ?? I have WindowsXP SP2, but I don't see anyplace where I can create subdomains, since everything are actually...
2
2745
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 = txtPassword.Text;
4
2034
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 among subdomains (limited ips supply). Iam looking for possible way to use subdomain.domain.com instead of ip address. Any inputs?? thanks
1
5648
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 keep the session (so I still know WHO has logged in)? The problem (as I see it) is the session-cookie. If that has a domain of "www.company.com", it will not be transferred to "my.company.com".
8
4302
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 subdomains that we've run into. -Kenny
1
3341
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) { String host = url.getHost().toString();
9
7793
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 in sessions? I can see active sessions in my mysql database, but is that the only place this information is stored? Sessions and cookies I know are related also, but how specifically (session info stored in cookies?)? Right now, when users...
3
2956
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 this weekend I tried to create some subdomains. For example, subdomain1.domain.com and subdomain2.domain.com. While Crystal Tech supports this, subdomains must point to an IP address. Therefore, it is not possible to point the subdomain to a...
3
6667
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 become bytes.com If it was subsubdomain.subdomain.bytes.com, it would become bytes.com
0
8312
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8504
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6169
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4159
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2732
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 we have to send another system

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.