Forum Discussion
Irule adding dns FQDN + appending url
I am using the iRule below to append a url to a VIP that is defined on our F5. Currently the output comes out as DNSshortname/url/url2. Our end user has requested that the URL show up using the fully quantified name. Can it be done so that the URL shows up using the fully qualtified name in the end users browser?
Example
So currently.
DNS/url/url2
Would like to change to below so that the full path is seen in the end users browser.
DNS.mydomain.com/url/url2
iRule in use
when HTTP_REQUEST {
if { ([HTTP::uri] equals "/") } {
HTTP::uri /page/page2[HTTP::uri]
}
}
4 Replies
- nitass
Employee
you may use HTTP::redirect.
HTTP::redirect wiki
https://devcentral.f5.com/wiki/iRules.http__redirect.ashx
e.g.[root@ve10:Active] config b virtual bar list virtual bar { snat automap pool foo destination 172.28.19.252:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { if { [HTTP::host] equals "DNS" and [HTTP::uri] equals "/" } { HTTP::redirect "http://DNS.mydomain.com/url/url2/" } } } [root@ve10:Active] config curl -I http://172.28.19.252/ -H "Host: DNS" HTTP/1.0 302 Found Location: http://DNS.mydomain.com/url/url2/ Server: BigIP Connection: Keep-Alive Content-Length: 0 - soda0091_86320
Nimbostratus
Thank you for the response. Can you explain what the code is doing so that I have a better understanding?
Thanks.
- nitass
Employee
Can you explain what the code is doing so that I have a better understanding?it does http redirection when http host header is DNS and uri is /.
more information about url and http redirection can be found in the following links.
5-Minute iRules: What’s a URL? by Jason Rahm
https://devcentral.f5.com/blogs/us/5-minute-irules-what-rsquos-a-url
Redirects, Rewrites and App Transfers via iRules by Colin Walker
https://devcentral.f5.com/tech-tips/articles/redirects-rewrites-and-app-transfers-via-irules - soda0091_86320
Nimbostratus
Thanks for your help.
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