peeked your curiosity yet? I've been reading through the forums, and can't seem to find an answer to my question, so here I am.
I inherited a project where users get their own subdomain with a set of 4-5 template php pages with semi-customizable content stored in a mysql database. It supposedly working before it came to me, now it doesn't, so I'm trying to debug the whole thing as
I have to duplicate the project for another domain, so I come to you, my gurus, after several hours, nay days, of research, dead-ends, and half-truths from the interweb.
I've been through the
IIS URL Rewrite page, looked around here and elsewhere, but I'm just getting confused.
I'm trying to accomplish the following for a growing number of users:
bubba.example.com ===> example.com/users/index.php?c=bubba
bubba.example.com/about.php ===> example.com/users/about.php?c=bubba
bubba.example.com/contact.php ===> example.com/users/contact.php?c=bubba
and so on... but I get 404 errors every time, regardless of the username/subdomain name or the template site. Some background info:
- running multiple domains/sites (primarily PHP) from same IP with IIS 7.5, php 5.3 and/or 5.4, and the URL rewrite module
- the default website/direct IP in IIS is pointing to our primary company's site.
- domain's DNS zone file has A records of "*" and "@" pointing to the webserver's IP
- we do have other specified CNAME entries for our own subdomains, like ftp, stmp, pop, admin, etc.
- web.config in this domain's root folder
I've had several versions of this first rule, via web.config and the IIS panel, and this is just the latest version, which I know doesn't work:
<rule name="User Sites" stopProcessing="true">
<match url="(.*)" />
<conditions trackAllCaptures="true">
<add input="{HTTP_HOST}" pattern="^(\w+)\.(example\.com)$" />
<add input="{HTTP_HOST}" pattern="^www\.example\.com$" negate="true" />
</conditions>
<action type="Rewrite" url="http://(C:1)/users/{R:0}?c={C:0}" logRewrittenUrl="true" />
</rule>
My next step was to set up rules for each template page, something like this (might not have the regexes right, but you get the idea:
<rule name="User about page" stopProcessing="true">
<match url="^about\.php$" />
<conditions trackAllCaptures="true">
<add input="{HTTP_HOST}" pattern="^(\w+)\.(example\.com)$" />
<add input="{HTTP_HOST}" pattern="^www\.example\.com$" negate="true" />
</conditions>
<action type="Rewrite" url="http://(C:1)/users/about.php?c={C:0}" logRewrittenUrl="true" />
</rule>
here's my latest rule, but it's still not working...
<rule name="rewrite">
<match url="(.*)?" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(?!www)(.*)\.(.*\.c.*)$" />
</conditions>
<action type="Rewrite" url="http://www.{C:3}/users/{R:0}\?c={C:1}" appendQueryString="true"
</rule>
I realize this one is overkill, as it would not be limited to just the 2 domains I want to rewrite, but I need something functional before I can refine, and this is still not working right.
Some help would be appreciated, even a push in the right direction