Forum Discussion
URL redirection with retaining the original on browsers
Hi All,
I have a requirement whereby the user would try to access www.test.com but it needs to be redirected to www.test.abc.com, which is hosted in our environment.
Business doesn't want to publish our brand name abc.com and therefore requested to retain only www.test.com in end user browsers.
Is there a way to achieve this using iRules ?
Quick response is highly appreciated.
Thanks in advance,
Sai
- BinaryCanary_19Historic F5 Account
You can accomplish this with Rewrite Profile: https://support.f5.com/kb/en-us/products/big-ip_ltm/manuals/product/ltm-implementations-11-5-1/23.html?sr=51290275
You could also point the DNS records for www.test.com to abc.com and simply use the same pool for abc.com as the pool for test.com. This will also require the web servers to be configured with a name virtual host (apache terminology) for test.com which uses the same web root as abc.com.
- MSK_222682NimbostratusIssue with playing DNS here is we do not own test.com and therefore cannot propagate in our DNS architecture
- Minn_62043Cirrostratus
Are trying to convert the links inside the HTTP response from www.abc.test.com to www.test.com again?
You can create a new stream profile to translate the domain names or use an iRule like this:
when HTTP_REQUEST { set to_change 0 if { [HTTP::path] contains "/urltomonitor" } { set to_change 1 } STREAM::disable } when HTTP_RESPONSE { if { $to_change == 1} { set original "http://www.abc.test.com" set replacement "http://www.test.com" STREAM::expression "@$original@$replacement@" STREAM::enable } }
You will need to modify the [HTTP::path] to match your url that contains redirection, and you still need to attach "stream" profile to your virtual server.
- MSK_222682NimbostratusHi Minn, Thanks for your quick response. I shall test this iRule in test infra. But can you help me understand how this above iRule (the commands) in it would be interpreted by BIGIP as I'm new to BIGIP technology and iRule code. Also, whats the role of "stream" profile in this case. Thanks again, Sai
- Minn_62043CirrostratusSo if a user is going to this url http://www.test.com/urltomonitor, and the page is redirecting the user to http://www.abc.test.com or if the page contains http://www.abc.test.com, iRule will replace that domain with http://www.test.com before sending the response to user, and user browser will never get to see www.abc.test.com.
- zeiss_63263Historic F5 Account
"user would try to access www.test.com but it needs to be redirected to www.test.abc.com"
The elephant in the room is whether you actually own test.com.
After that, you don't need rewrites or redirection, you simply need to point the DNS record to the same IP as www.test.abc.com and tell the web servers that serve www.test.abc.com to serve the same page(s) when the HTTP "Host:" header contains www.test.com.
Of course if your webpages contain hard links (rather than relative ones) you'll need to do some STREAM changes to alter URLs-on-the-fly, per the post from Minn.
- MSK_222682NimbostratusHi Zeiss, We do not own test.com and therefore the problem. Let me try the iRule given by Minn and get back to you all. Thanks for the quick response. Sai
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