Lawrence
Lawrence

Reputation: 727

Url Rewrite Help required

i'm still so new to url rewrite. Need some help here.

I'm trying to set a different subdomain name to each of the countries on my site.

Did some research, here's what i got

    RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com$
    RewriteRule ^=(.*)$           http://mydomain.com/o9_advertiser/ad_list/ad_list.php?country=$1 [L,R] 

Would appreciate it if anyone can provide some help here. Thanks.

Upvotes: 1

Views: 90

Answers (1)

undone
undone

Reputation: 7888

    RewriteCond %{HTTP_HOST} ^(.+)\.o9village\.com$
RewriteRule (.*) o9_advertiser/ad_list/ad_list.php?country=%1 [L]

In first line, it checks whether it's something like iran.mydomain.com or not? if yes, it goes to rewrite rule which redirect user to http://mydomain.com/o9_advertiser/ad_list/ad_list.php internally (User can not see the redirection in his/her browser). if you use var_dump function in ad_list.php to see $_GET array, you will see something like:

array(2) {
  ["country"]=>
  string(4) "iran"
  ["path"]=>
  string(9) "index.php"
}

Edit: OK, Log into your CPanel account, create a sub-domain *.o9village.com. set Document Root to point at Document Root of your main domain o9village.com. Now, if you browse iran.o9village.com, you will see same page as http://o9village.com/o9_advertiser/ad_list/ad_list.php?country=iran

Upvotes: 1

Related Questions