I made one php project in which we provide facility to create his/her own web site.
Now I wants to add new feature giving different subdomains to the
members' web pages.

Because the number of members is about 120,000, manual configuring is
not the solution.

Let me give you an example.
1) We have domain name such as 'osteopathicwebsites.com'.
2) Someone joined osteopathicwebsites.com with account 'mxi'.
3) He get his own direcory in our Web server such as /mxi/.
(It's url become 'http://www.osteopathicwebsites.com/mxi/' for redirecting his own page.)

4) And I required he should get the subdomain 'mxi.osteopathicwebsites.com' (How can we
implement this???)

If anyone have any any idea then please suggest me.I also try myself by google.

Recommended Answers

All 4 Replies

I made one php project in which we provide facility to create his/her own web site.
Now I wants to add new feature giving different subdomains to the
members' web pages.

Because the number of members is about 120,000, manual configuring is
not the solution.

Let me give you an example.
1) We have domain name such as 'osteopathicwebsites.com'.
2) Someone joined osteopathicwebsites.com with account 'mxi'.
3) He get his own direcory in our Web server such as /mxi/.
(It's url become 'http://www.osteopathicwebsites.com/mxi/' for redirecting his own page.)

4) And I required he should get the subdomain 'mxi.osteopathicwebsites.com' (How can we
implement this???)

If anyone have any any idea then please suggest me.I also try myself by google.

Here is one way to do it:

You need to be able to edit your dns records. Add a wildcard entry for your domain.

Then configure your webserver to serve for each subdomain as well. This depends on the webserver. With apache it would involve creating a virtual host (edit http.conf) and have it serve for your subdomains.

eg:

<VirtualHost *.osteopathicwebsites.com>
ServerAdmin webmaster@osteopathicwebsites.com
DocumentRoot /path/to/osteopathicwebsites.com/root/
ErrorDocument 404 /404.html
ErrorLog /etc/log/osteopathicwebsites.com/error.log
TransferLog /etc/log/osteopathicwebsites.com/access.log
</VirtualHost>

It would actually just mimic what osteopathicwebsites.com has configured, and point to the same document root. So that osteopathicwebsites.com serves all documents for any subdomain.

Then in your php, check for the subdomain, I believe it should be $_SERVER. Then display the users page based on that...

as far as I know, a sub domain " sub_domain.domain.com " can't be created by a PHP script or any other script at that.
It's a question of a server configuration.
If you have access to your host server admin area (Like PLESK) you might have the option to create them yourself. If not you will probably have to contact your host company and ask them to create one for you.

3) He get his own direcory in our Web server such as /mxi/.
(It's url become 'http://www.osteopathicwebsites.com/mxi/' for redirecting his own page.)

I oppologize I mis-read your situation.
This IS possible.
use a simple redirect to redirect them, have the php create a file on your server, with read and write access granted to that user (this will require the edit of your .htaccess file.
when they log in on your main site their user name (from your database) will redirect them to their home page. in order for them to upload their files is another issue as you dont want them to have full access to your ftp nor your databse. so you will need to set up a control panel for each new site with permisions being restricted to that person for uploads and edits of their own files, etc etc.

Its not all that difficult but it is time consuming. this such a thing could take as many as 10 php scripts all running together and security should be your biggest concern for offering free web hosting.
Also you may find yourself inside legal ramifications if the host who is hosting your site finds that you are using their service to host other sites without their consent.

Thanks everyone, and yes i need virtual domain setup access in hosting panel then after i can choose on which way i want to go.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.