开发者

set up way of getting mysite.$domain

I have several domains, only one website and one databse table for each domain.

example: wbesite.us - data from USA goes to database table main_usa

wbesite.co.uk - data form UK goes to database table main_uk

Only have one database with name of the website. Having only one website structured and having variables like this:

$sql="select * from main_".$countrycode." where bla..bla...

and many other variables to catch the domain extension, and so on...

Now, instead of having one full website for each domain, how can set a script and wher do I put it in o开发者_开发技巧rder to detect the domain that the user uses.

In my server root do I create something like website.$domain?

Something like website OLX but for different purposes.

I hope I made myself clear.

Thank you.


You could use the $_SERVER['SERVER_NAME'] global and somehow parse it, to get the country code.

I didn't try it, but something like this should work:

$servername_array = explode('.', $_SERVER['SERVER_NAME']);
$country_code = array_pop($servername_array);

That way, $country_code will be com, uk, or whatever is after the last dot in the domain name.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜