2

I have set up a subsystem in my app:

example.com/index.cfm/subsys:foo/bar

What I want to do is map a subdomain to that subsystem to eliminate the need for the subsystem specification in the PATH

subsys.example.com/index.cfm/foo/bar

We serve our FW1 app through IIS6 currently, but may migrate to Apache, so a solution in either is acceptable.

Kyle Macey
  • 8,074
  • 2
  • 38
  • 78

1 Answers1

1

With Apache's mod_rewrite you can do something like:

RewriteCond %{HTTP_HOST} ^(subsys)\.example\.com
RewriteRule /index.cfm/(.*) /index.cfm/%1:$1

To make it work with multiple subdomains/subsystems, use a pipe-delimited list inside the parentheses:

RewriteCond %{HTTP_HOST} ^(sub1|sub2|sub3)\.example\.com

To make it work for any non-www subdomain, for any domain, use a condition such as:

RewriteCond %{HTTP_HOST} ^((?!www\.)\w+)\.


For IIS6, you would probably need third-party software, such as Helicon Tech's ISAPI Rewrite, which supports mod_rewrite syntax.

Peter Boughton
  • 110,170
  • 32
  • 120
  • 176
  • I've come across this solution, my only beef with it is that it's kind of static. What I mean by that is, you have to have the hostname in the definition. This makes it difficult to run across several domains (We have different domains bound for local development, staging and production) – Kyle Macey Jan 25 '13 at 18:50
  • However, if nothing else comes up, this might be what I'll end up going with – Kyle Macey Jan 25 '13 at 18:51
  • You don't _have_ to have the hostname there - you could adapt the first line to something like `^((?!www)\w+)\.` to make it work for any non-www subdomains. – Peter Boughton Jan 25 '13 at 18:54
  • Then would I be able to match the subdomain dynamically to a subsystem as well? That sounds magical – Kyle Macey Jan 25 '13 at 18:56
  • Probably, but I'm not quite sure what you're asking there? The subdomain is linked by using a capturing group in the RewriteCond plus the %1 in the RewriteRule (as opposed to the regular $1 which is for captured groups from the rule itself). – Peter Boughton Jan 25 '13 at 18:59
  • Ok, that seems to answer it. Thanks a lot! – Kyle Macey Jan 25 '13 at 19:59