views:

175

answers:

2

I have used the Apache Mod Rewrite for PHP but not in IIS.

BACKGROUND:

I have inherited over 400 sites on IIS with PHP all with a copy of the identical code base. The current code base has a unique connection string per client and that is why it was copied over and over again.

Each being a subdomain pointing an individual site in IIS:

  • customer1.mysite.com
  • customer2.mysite.com

I have used Sessions and PHP to get to a single code base with each site pointing to its own directoy that contains a single PHP file that pulls variables from the database master table and places them into Session strings using a virtual directory for the now single code base.

But now I want to take it a step further. The idea for this came from using Zend bootstrap with Apache.

My next step is to eliminate the indiviual PHP files and use a bootstrap file along with a single code base in a single directory on a single IIS site. www.mysite.com

QUESTION

I want to know if it is possible to do a rewrite rule so that any subdomain on mysite.com goes to mysite.com/bootstrap.php thus customer1.mysite.com goes to www.mysite.com/bootstrap.php and customer2.mysite.com goes to www.mysite.com/bootstrap.php but the subdomain stays in tack - even though it is just one site.

So that a call to: customer1.mysite.com goes to www.mysite.com and the bootstrap can read the subdomain, look up the site parameters, place them in sessions, and then allow access to the site.

Or if you know of a better way to accomplish this please let me know but I cannot change the 400 plus subdomains the clients are using to access the product.

+1  A: 

If you are using ISAPI Rewrite (A ModRewrite for IIS), you could have your bootstrap.php look at the "X-Rewrite-URL" HTTP header, which is the original, unmodified, URL, and make a decision on what to show based on that.

Michael Morton
A: 

Rewrite would not work because the wildcard is not allowed. So I had to add each subdomain to a single folder. A little more work but it solved the problem.

Todd Moses