how can i create a subdomain using php?
Thanks in advance
You can't, Sub-Domains are managed by the web server. Speak to your host for information on how to set one up.
I'm a beginner,
I mean is there any way to create a subdomains like some free hosting sites do?
Is there any other way to make subdomain creation upon user request.
I used create sub domains from my control panel.
i don't know what actually CGI is, is it possible with that? or ruby or perl?
Forgive me if my question is a blunder :).
Thanks a lot for your reply.
unix-like or windows server?
The only way that I know how to make subdomains (other than using the servers control panel) is by editing the apache httpd.conf file which you may be able to program a php script to do if you have full permissions of the server. Guides can be found at http://apptools.com/phptools/virtualhost.php So if you are the server administrator then just program a php script to edit the httpd.conf file as instructed in the above and the apache codes would look something like:
NameVirtualHost realdomain.com <VirtualHost realdomain.com> DocumentRoot "C:\My Sites\Site1" ServerName subdomain.realdomain.com </VirtualHost> <VirtualHost realdomain.com> DocumentRoot "C:\My Sites\Site2" ServerName realdomain.com </VirtualHost>
And obviously replace in the code above the term "realdomain.com" with your registered domain and replace the word "subdomain" with the name of your subdomain. But that is a sketch of what I think the apachie code needs to look like but would wait for further comments on the above code before copying it.
Also in the link I provided, you will need to ignore the information below the title: "Resolving the DNS issue" as you have a domain in the first place instead of localhost.
So basically, the only thing that php can really do is edit the apache httpd.conf file.
You need server root access in order to manually modify the httpd.conf file. Very few hosting companies will give a site owner root access. Using cPanel to add a subdomain does the same thing.
Unless you are very familiar with Linux/Unix servers, you should not be doing anything at the server root level.
I think what you really want to do is to set up a widcard DNS that allows you to artificially create sub domains. I have used this article to do that. The article also shows you how to manually edit the httpd.conf file.
Another option would be to create subdirectories for your users with PHP. That is easier to do.
Thanks for your reply, I don't have the login details for my DNS ("Edit DNS Zone") configuration
I only have username and password for my cpanel. Then it seems to be a difficlut job for me. Also i didn't get you completely (wildcard DNS).
also I think I have to switch to the second methid you've suggested.:)