At wit's end with URL REWRITING

In short, I am on IIS, but I was hoping some people with URL Rewriting experience could just lend some advise.

I have a website whose root site is located at c:\web-root\intranet.

Directly below that are a bunch of folders which act as the subdomain to the intranet, ie:

c:\web-root\intranet\apps (this hosts the apps.intranet subdomain content)
c:\web-root\intranet\files (this hosts the files.intranet subdomain content)

There are only 2 subdomains that I want to rewrite to an actual file: ACP and the default (none or ‘www’ specified). So in essence, a request to:

acp.intranet/this/that REWRITES TO /acp/index.cfm?ses=/this/that
www.intranet/this/that REWRITES TO /www/index.cfm?ses=/this/that
intranet/this/that REWRITES TO /www/index.cfm?ses=/this/that (notice that when no subdomain is specified, I want to use www as the default)

Notice that with the above subdomains the “/this/that” is not an actual file/directory location that exists within those folders. Once IIS hands off the rewritten request to ColdFusion (index.cfm) it will use that data to indicate where the user was trying to get to.

But for ANY OTHER SUBDOMAIN, I want it to rewrite as the following

files.intranet/this/that REWRITES TO /files/this/that
apps.intranet/this/that REWRITES TO /apps/this/that

Notice that with these subdomains, the “/this/that” is referencing files and folders to be served to the user. For example:

files.intranet/docs/file.doc WOULD BE REQUESTING /files/docs/file.doc (to be served up)

I hope I have explained this correctly. If someone can suggest some code to help me get there, I’d very much appreciate it. I don’t want to post what I have cause it’d be pointless, as I’m not getting the desired result.

Well…I think the problem is that you are making this way to complicated…
Forget multiple subdomains, have everything be as its own site. Thus the apps, files, acp subdomains would have their own configuration. Next, www and non-www should just be pointed to the same exact thing, don’t go rewriting anything about that other then to change the domain to either with www or non-www prefix.

Logic_earth-

Thanks for the reply; I DO have a bad habit of sometimes over complicating things. I have played with the thought of making each subdomain it’s own site, but if I do this I guess I would have some other questions to ensure proper rendering of files.

First of all, you’re saying that:

acp.intranet would have a root location of c:\web-root\intranet\acp
files.intranet would have a root location of c:\web-root\intranet\files

www.intranet would have a root location of c:\web-root\intranet\www
intranet would have a root location of c:\web-root\intranet\www (same as www subdomain)

So in essence, if I am in, say, acp.intranet, and code in there references an absolute path like “/test/file.cfm” then the interpreted location of the acp.intranet site is c:\web-root\intranet\acp\ est\file.cfm.

Am I understanding you correctly?

Most likely. It would be how I would set it up. However, since I’m looking from in the outside it I can only being advice from that position. I don’t know the full requirements or constraints. But yes, the root of each sub/domain would be at their own roots.

Well, I set it up and things seem to be working well. The setup allows me to basically have a .htaccess file for each subdomain. Now I don’t have to worry about processing the host name, which is kinda nice.

I guess the idea of having a 1 stop shop .htaccess file was alluring as far as management goes. But for the subdomains that don’t need any rewriting essentially, at least with this setup I don’t have to rewrite to the subfolder.

Thanks for helping me see the more clear solution. Hopefully I’ll remember why this is the better way to go if I down the line question why I have so many sites defined in IIS. :slight_smile: