Forum Discussion

Joel_43353's avatar
Joel_43353
Icon for Nimbostratus rankNimbostratus
Mar 20, 2013

How to direct traffic to different folders based on incoming subdomain?

Hi,

 

 

I am stumped on writing an iRule to take in the URL coming on a shared VIP (DNS entry set for different sub domains to go to the same VIP) and direct to the proper folder in the IIS pool based on the incoming sub domain. Any help would be greatly appreciated. I am fairly new at this and I am thinking this is a fairly easy iRule to write.

 

 

Example:

 

 

https://one.mydomain.com/ maps to http://[HTTP:host]/appone

 

https://two.mydomain.com/ maps to http://[HTTP:host]/apptwo

 

 

where one.mydomain.com and two.mydomain.com have a DNS entry for each pointing to a shared VIP and web pool.

 

 

 

Normally, I would farm these out to different pools, but due to some development related issues, that isn't an option at this time.

 

 

Again, any help is greatly appreciated.

 

Thanks.

 

J

 

5 Replies

  • t-roy's avatar
    t-roy
    Icon for Nimbostratus rankNimbostratus
    You sure you want to redirect HTTPS to HTTP? This should work:

     

    when HTTP_REQUEST {

     

    switch [HTTP::host] {

     

    "one.mydomain.com" { HTTP::respond 301 "http://one.mydomain.com/appone" }

     

    "two.mydomain.com" { HTTP::respond 301 "http://two.mydomain.com/apptwo" }

     

    }

     

    }
  • @T-roy ... I am not necessarily looking at sending a redirect to the browser. These apps are technically coming in on the same VIP and using the same web pool. I am looking to forward it to the correct IIS path based on the incoming sub domain.
  • I think using the word "direct" is a little misleading. I am looking to do a re-write based on the incoming subdomain.
  • t-roy's avatar
    t-roy
    Icon for Nimbostratus rankNimbostratus
    Gotcha, see 2: https://devcentral.f5.com/tech-tips/articles/redirects-rewrites-and-app-transfers-via-irules

     

     

    That should get you what you need!