How do you create subdomains using PHP?

Author Topic: How do you create subdomains using PHP?  (Read 1158 times)

Offline chinmay.sahooTopic starter

  • Trade Count: (0)
  • Full Member
  • ***
  • Thank You 2
  • Posts: 159
  • Karma: 0
    • Hot Shaper
How do you create subdomains using PHP?
« on: 04-11-2016, 05:34:14 »
1) Restart httpd
2) Edit httpd.conf


Offline TomClarke

  • Trade Count: (0)
  • Hero Member
  • *****
  • Thank You 18
  • Posts: 898
  • Karma: 0
  • Gender: Male
    • Custom Writing Service & Content Marketplace
Re: How do you create subdomains using PHP?
« Reply #1 on: 05-11-2016, 01:55:20 »
Here is a great article on this topic http://www.careerride.com/PHP-sub-domains.aspx
You can read how to create subdomains using PHP step by step!
Your ideas, our writings - Writology.com

Offline Gharkul

  • Trade Count: (0)
  • Semi-Newbie
  • *
  • Thank You 0
  • Posts: 13
  • Karma: 0
Re: How do you create subdomains using PHP?
« Reply #2 on: 08-08-2016, 06:29:44 »
Dynamic subdomains like Google Blogger and Tumblr.com, I know most of the people are looking for better solution. Today I want to explain how to achieve this using .htaccess with PHP. I especially love to write .htaccess file, using this you can easily host multiple domains in single server. This dynamic subdomain system is the base for cloud services, soon I will come with new tutorial. I hope this post will solve your problem.

Offline pablohunt2812

  • Trade Count: (0)
  • Full Member
  • ***
  • Thank You 8
  • Posts: 205
  • Karma: 0
Re: How do you create subdomains using PHP?
« Reply #3 on: 10-19-2016, 01:57:08 »
use this script to add new subdoamin in your cpanel account

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);
}

 

Related Topics

  Subject / Started by Replies Last post
3 Replies
1327 Views
Last post 05-30-2012, 22:16:43
by ring2012
0 Replies
919 Views
Last post 04-04-2013, 15:04:42
by billie_m
0 Replies
653 Views
Last post 02-29-2016, 08:07:57
by HareKrishna
0 Replies
569 Views
Last post 06-30-2016, 14:33:56
by PrimoPierotz
2 Replies
520 Views
Last post 02-28-2017, 22:33:17
by Michealyardy