| | Hi, can anyone teach me how to make autocreation of subdomain like blogspot.com or http://cmblog.mobi. I`m clueless about making this. Thank you and please help me. |
| Nov 22, 2009 |
Another way is to fake a subdomain using mode rewrite to make anything.example.com work and anything could be written, but for that you need to edit httpd.conf even though I never understood how, maybe after 4 years there are more resources on google to find out Anyway, you would need more permissions to do that, if you're using a simple hosting, I doubt you could simply access httpd.conf and I don't know if it could be done by just using .htaccess as it also requires to do something with DNS after you create a directory.. You would need to have a server Just did a quick search and found another interesting method to do it using PHP, by connecting to CPanel if you're using it and making PHP create the subdomain through CPanel subdomains, of course I don't know if the script works, but it's really logical and I think you need to be careful to include it in your scripts, you need to write your CPanel username and password and the script will use those and make a request as if you would do it through CPanel! Here is the script: CODE subdomainform.php <html> <head> <title>create a subdomain</title> </head> <body> <form name="form1" method="post" action="addsubdomain.php"> <h1>create Sub Domains</h1> Sub Domain Name : <input type="text" name="subdomain"><br /> <input type="submit" name="Submit" value="Submit"> </form> </body> </html> ============================== addsubdomain.php ============================= <?php ini_set('display_errors', 1); $host = "domainname.com"; // your domain name without the www $port = 2082; $path = "/frontend/x/subdomain/doadddomain.html?domain=".$_POST['subdomain']."&rootdomain=".$host; //or .dll, etc. for authnet, etc. // these lines are changed $cpaneluser = "username"; $cpanelpass = "pass"; $authstr = "$cpaneluser:$cpanelpass"; //**************************** // Setup the Auth String $pass = base64_encode($authstr); $fp = fsockopen($host, $port, $errno, $errstr, $timeout = 30); if(!$fp){ //error tell us echo "$errstr ($errno)n"; }else{ //send the server request fputs($fp, "POST $path HTTP/1.1rn"); fputs($fp, "Host: $hostrn"); fputs($fp, "Authorization: Basic $pass rn"); fputs($fp, "Content-type: application/x-www-form-urlencodedrn"); fputs($fp, "Content-length: ".strlen($poststring)."rn"); fputs($fp, "Connection: closernrn"); fputs($fp, $poststring . "rnrn"); //************************************* // Remove this to stop it from displaying the output fron the CPanel //************************************* //loop through the response from the server /* while(!feof($fp)) { echo fgets($fp, 4096); } */ while(!feof($fp)) { fgets($fp, 4096); } //close fp - we are done with it fclose($fp); }
That is a great script, isn't it a bit risky putting your cpanel username and password in there though? many people can easily access it and download it, then they have access to your account...
PHP is executed on the server, not by the client. The user only sees what is outputted with echo, so only the response from adding the subdomain will be shown.
I think the script is missing an ending ?>
No, but the client can still download the PHP file... Do you see what am getting at, you would need to lock the folder the PHP is in so no one in the public can grab it out of your server space...
No, but the client can still download the PHP file... Do you see what am getting at, you would need to lock the folder the PHP is in so no one in the public can grab it out of your server space... Its impossible to unless you make it download from within the php file itself. A user cannot download the source code of a php file
Yes you can, all you need to do is go to your download manager and paste in the address and there you go, you have the PHP file.
Now what I would usually do is create a cname record that points to the necessary servers to do what you aim to do.
CNAME RRs incur performance overheads. The most common DNS query is for an A RR, or an AAAA RR if IPv6 - the end system needs an address which is only defined with these RR types. In the above example if a query for the address of www.example.com is received, two look-up operations are performed on the master or slave server. The first finds www.example.com which finds a CNAME RR. This is followed by a query for server1.example.com to obtain the IP, that is, the CNAME chain is followed to attempt to resolve the request for an IP address. On low volume DNS servers the additional resources used are not significant but on high volume servers the additional load can become non-trivial. The user must make a choice to balance what many see as the convenience of using CNAME RRs against the possible performances degradation involved. CNAME RRs cannot have any other RRs with the same name, for example, a TXT - well that was true until DNSSEC came along and in this case RRSIG, NSEC and certain KEY RRs can now occupy the same name. While use of CNAME RRs with NS and MX records is widely implemented and generates a working configuration it is theoretically not permitted (RFC 1034 section 3.6.2) since it can result in lost names. The fragment below illustrates a widely used but technically invalid configuration.
Similar Topics
Keywords :
How can i do this? (5) Hey all. Now i have a DB, an SQL DB, and i need to auto prune the data there to delete rows lder Php Coding (3) Hello...I'm designing a website in PHP where ppl can submit their links for "cool sites". How to suppress auto generated mysql err (4) I am testing my website on my local machine. It is still in development stage and I am using phpMyadmin (15) hi, Can we reset the id auto increment in the mysql database using by phpMyadmin? let's say the auto set it, how? (4) I have some problem about set permissions by automatic.. for example... I created txt file with Looking for Auto, Creation, Of, Subdomain
|
![]() Auto Creation Of Subdomain |
Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com