Jump to content

Single database running two (or more sites) country specific


Recommended Posts

Happy new year everyone!

 

Can someone help me please.  I have a skadate script installed on a domain and want to set up sub-domains based on the users country of registration - ireland.mydomain.com, france.mydomain.com etc

 

I know that I can install the skadate script within subdomains and refer to the same primary database BUT what I want to do is only show say users registered in Ireland on the ireland.mydomain.com site.

 

Can this be done via the database connection string??

 

// MySQL Connection

define('DB_HOST', 'localhost');

define('DB_USER', 'user_skadate');

define('DB_PASS', 'abc123');

define('DB_NAME', 'user_skadate');

define('DB_TBL_PREFIX', 'skadate_');

 

This is the config.php database string.

 

Any advice or suggestions would be very gratefully recieved.

You should define a catch-all DNS entry:

 

*.<your-domain> IN A <ip>

 

Then in your PHP script:

 

$country = array_shift(explode('.', $_SERVER['HTTP_HOST'])); // ireland, france, ..

 

Be sure to filter $country and validate before using it in a database.

Thanks for your reply, I think I may not have explained fullly, because as I believe $country is a standard php function and what I needed was to use members based on a field they'll have completed (country_id)

Do you have a control panel of your server with DNS access? If so, open it and add a new entry:

 

*.your-domain.com IN A your-ip-address

 

This will "forward" everything to your-domain.com and allows you to handle it like this:

 

$country = array_shift(explode('.', $_SERVER['HTTP_HOST'])); // eg ireland, france, or www

 

Add the necessary code to handle www, ireland and france. If this feels over your head, hire a freelancer/programmer to do it for you.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.