2

i want to have several subdomains for my CakePHP application, like

http://app1.mydomain.com, http://app2.mydomain.com, http://app3.mydomain.com, http://app4.mydomain.com, etc.

how can i use app1, app2, app3, etc, as variables in my application (ie. every subdomain will have unique design)?

is it possible to "parse" url with .htaccess, or it's better to use php functions to achieve that?

tnx in adv!

user198003
  • 11,029
  • 28
  • 94
  • 152

2 Answers2

1

You don't need any .htaccess rules for this. You can simply determine it in PHP with:

$subdomain = strtok($_SERVER["HTTP_HOST"], ".");

Take care that this is a user-supplied value. (Apache only whitelists the first level vhosts.)

mario
  • 144,265
  • 20
  • 237
  • 291
1

Create Subdomains on the fly with .htaccess (PHP) Create subdomains on the fly with .htaccess (PHP)

Community
  • 1
  • 1
Mohammad Efazati
  • 4,812
  • 2
  • 35
  • 50