Jump to content

Need help to implement mod rewrite by URL


kee2ka4

Recommended Posts

Hello everyone,

 

I need help on implementing the mod rewrite so the database can be queried by the URL name.

 

So for example if the user types in www.site.co.uk it querys the database and only displays results located in UK and for example if the user types www.site.com it displays results located in USA. Can someone please help me on how I can modify the mod rewrite to acheive that.

 

Thanks,

Zub

you don't need mod_rewrite for this

 

$parts = explode($_SERVER['HTTP_HOST']);

$domain = array_pop($parts);

switch ($domain) {

  case 'com':

      ..

      break;

  case 'uk':

      ..

      break;

  default:

      .. default behavior

      break;

}

Hi, thanks for the reply. I did consider that option at frist but I also need to futher query the database by cities, so if the url is london.site.co.uk it displays results located in london. Sure I can include another case:

 

case 'london':

        ..

        break;

 

But I think that will generate a very long switch case statement. I will start off with the switch case method but is there any better way of doing this.

 

Thanks,

Zub

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.