First you need to set your main domain to act as a catch-all subdomain. its like putting ServerAlias * so that each subdomain which is requested
to the main domain reaches the same place. I mean if your main domain root is
/home/admin/abc.com/htdocs/
then your catch-all setup shall send all sub-domain requests to that same directory
/home/admin/abc.com/htdocs/
and then in the index.php file of this directory you can do this
global $domainname;
global $subdomainname;
$domainarray = explode('.', $_SERVER['HTTP_HOST']);
$index=count($domainarray)-1;
$domainname= $domainarray[$index-1].".".$domainarray[$index];
$subdomainname="";
for($i=0;$i<$index-1;$i++)
{
if($subdomainname=="")
{
$subdomainname=$domainarray[$i];
}
else
{
$subdomainname=$subdomainname.".".$domainarray[$i];
}
}
ShowCustomizedPageForsubdomain($subdomainname);
?>
This function ShowCustomizedPageForsubdomain($subdomainname) can be easily implemented in two ways:
1) Either your store Page's Html in your database and all this function would do is to pick up that html code for the provided sub-domain from the database and simply
"echo" or "print" it.
2) or you can simply have standard actual pages for each subdomain and you simply include them here like this
ob_start();
include "http://url_of_the_page_you_want_to_show";
$data=ob_get_contents();
ob_clean();
this Object buffer will return you that page's content in the variable "$data"; you simply echo $data;
Second Implementation of your function is like this
function ShowCustomizedPageForsubdomain($subdomainname)
{
ob_start();
include "http://url_of_the_page_you_want_to_show_for_this_subdomain";
$data=ob_get_contents();
ob_clean();
echo $data;
}
Think Different: Your FREE daily tech stories on AI, Data Science, ML, IoT, Cloud, Open Source, Python, Rust, Golang, DevOps, Management & the future of human-machine interaction. All the latest tech, from around the world.
Subscribe to:
Post Comments (Atom)
Django URLs
In Django, the urls.py file is where you define the URL patterns for your web application. There are several ways to write the urls.py fil...
-
The client want to have a shop where regular customers to be able to see products with their retail price, while Wholesale partners to see t...
-
URL based session management does not only have additional security risks compared to cookie based session management, but it can cause also...
-
I have curated the learning pathway for you to learn Machine Learning and Data Science. You can follow the Google Classroom paths below: E...
-
Widgets and gadgets are small applications that run on your desktop or in your web browser which enable you to keep track of things like the...
-
When developing a Web application, it's standard practice to create a database structure on which server-side code is placed for the lo...
-
IoT (Internet of Things) : IoT refers to the interconnection of everyday objects, devices, and appliances to the internet, allowing them t...
-
Photo by Acharaporn Kamornboonyarush Let's compare MongoDB and InfluxDB by prov...
-
pic: microsoft Power BI Overview: Power BI is a business analytics tool by Microsoft that allows you to visualize and share insights from ...
-
Photo by Nana Dua Let first recap what is CPU and GPU. Image courtesy: researchgate Central Processing Unit ...
-
Abstract: A solar tracking system is a device or mechanism designed to orient solar panels, solar collectors, or other solar energy harvest...
No comments:
Post a Comment