php - Regional subdomains -


i want make regional subdomains of current site.com - city1.site.com , city2.site.com, don't want copy files original domain subdomain.
possible show on subdomain city1.site.com same info on site.com set 1 variable, $city = 123? variable on city1.site.com can show more specific contacts , products city.

i'm new subdomain please help, site on php & mysql. thank you!

if have few regions, can manually create subdomains each region , point domains same folder main site. in script grab host , match regions , assign desired value variable.

<?php if($_server['http_host'] === 'city1.site.com') {   $city = 123; } else if($_server['http_host'] === 'city2.site.com') {   $city = 223; } 

if have many regions , want dynamic match, can match subdomain main site path , inside script can use method subdomain , search in database. example:

<?php  $subdomain = strstr($_server["http_host"], '.', true);  $city = getregion($subdomain);  if(!$city) {  // throw 404 error   header('http/1.0 404 not found');   exit; } // getregion($subdomain) method should search database match subdomain region 

to match subdomains path need use wildcard in cpanel. see tutorial: https://www.namecheap.com/support/knowledgebase/article.aspx/9191/29/how-to-create-a-wildcard-subdomain-in-cpanel


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

python 3.5 - Pyqtgraph string in x tick -