It is not quiet easy to setup a wild card domain. To setup a wild card domain on your Cpanel server you will need to do this. Do the following steps :
First thing you must have a access to the Edit DNS Zone on your server. Whether it si WHM or Cpanel. You will get this option under DNS functions. Click on Edit DNS Zone. Select the domain of your choice to use. Do not edit any of the server in the list. Just the only you need to. Go down and look for Add New Entries Below this Line. Put * in the first box, followed by your server IP address in the place of 65.66.67.68.
The second part is to connect to your sever through SSH. You can use a simple tool call Putty to access it. If you have any other tool you can use that also. The idea is that you must have a program that is capable of accessing a server through SSH. Now launch the Putty tool. In the Putty configuration window enter your server's IP address. The port should be 22, unless you've configured your SSH access to another port. Click on Open. Now type the following text into Putty window :
* login as: username
* password: password
* enter: cd /etc/httpd/conf/
* enter: pico httpd.conf
* press: ctrl w
* enter: youdomain.com
Now edit the line : ServerAlias yourdomain.com to: ServerAlias: *.yourdomain.com yourdomain.com. Now click ctrl x to exit. Save your work. Now you are done with configureing your server to use a wildcard dns for your subdomain.
At last you to get your wildcard subdomain name with PHP
PHP Code:
$serverhost = explode('.',$_SERVER["HTTP_HOST"]);
$sub = $serverhost[0];
if ($sub = "www") {
$sub = "";
}
Insert the above php code in your main php file. By the above code use appropriate setting for your sub domains.
Bookmarks