Forum Discussion
How to redirect user to URL based on entered CNAME
I apologize if this has been asked and answered in the past, but I'm not sure which keywords I should be using to find what I'm looking for.
What I'm trying to do is when a user enters 'service-a' in a browser, we want the GTM to direct the user to "http://service-a.company.com". If they enter 'service-b' in the browser, we want to direct them to "http://service-a.company.com/service-b".
Can this be solved with just an iRule on the GTM? Or is this mostly an LTM solution?
Thanks everyone.
1 Reply
- Kevin_Stewart
Employee
Just a thought, but the first issue is generally resolved with a CNAME. I don't believe GTM can natively issue a CNAME from a given short name, so an iRule like this (applied to the LTM listener VIP) could work. This is a very simple example, so I'm sure there's a better way.
when DNS_REQUEST { switch [string tolower [DNS::question name]] { "service-a" { DNS::answer insert "service-a CNAME service-a.company.com" DNS::return } "service-b" { DNS::answer insert "service-b CNAME service-b.company.com" DNS::return } } }Where "service-a.company.com" and "service-b.company.com" resolve to the same virtual server IP. Then use an iRule on the VIP that validates the Host header:
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "service-b.company.com" } { HTTP::redirect "http://service-a.company.com/service-b" } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com