为每个指向同一服务器的域维护唯一页面

Am working on a project that will run for multiple countries.

  1. mydomain.com
  2. mydomain.co.ke
  3. mydomain.co.sa

All the domains are pointing to same file.

My challenge is that i have few pages that should be unique for each country.

Example of such page is the xml feed page

Please how do i achieve that

Thanks

Some suggestions...

Alternative 1 using SetEnv Apache Module:

  • All domains should points to same server
  • On Apache create a vhost for each domain
  • Use SetEnv module for set custom env variable, you will set on vhost file
  • Apply your business logic based on env country var recovered use getenv function for that

vhost example:

<VirtualHost *:80>

   ServerName mydomain.com.br
   DocumentRoot /var/www/html/MyDomain

   SetEnv APPLICATION_COUNTRY "brazil"

</VirtualHost>

on php:

$country = getenv('APPLICATION_COUNTRY');

# your business logic here...

Alternative 2 without SetEnv Apache Module:

  • All domains should points to same server
  • On Apache create a vhost for each domain
  • Create a bootstrap.php (entry point) that will figure out country matching $_SERVER['SERVER_NAME']
  • Apply your business logic based on var set

You can start creating an associative array to control custom pages visibility based on country var recovered.