Forum Discussion
Rewrite URL using irule from internal to External
Hi All,
I am trying to rewrite URL from internal to external by applying the mask on header. It is working as expected using below irule however if I select some hyperlink or option, its showing actual url information which we would like to prevent that, as client should not recognize where they are getting redirected.In our example, I am forwarding users who are trying to access 123.abc.com/xyz/ to , till here it is working as expected but after it got redirected, if I select any option or hyperlinks, its no rewrite the URL information.
when HTTP_REQUEST { if { [HTTP::host] eq "123.abc.com" and [HTTP::uri] contains "/xyz/" } { if {[string tolower [HTTP::uri]] contains "/xyz"}{ set uri [string range [HTTP::uri] 4 end] HTTP::uri $uri HTTP::header replace host "; pool testGoogle log local0. "[IP::client_addr]:[TCP::client_port]: Replacing Host with http://[HTTP::host]HTTP::uri" }}}
- PeteWhite
Employee
when HTTP_REQUEST { if { [HTTP::host] eq "123.abc.com" and [HTTP::uri] contains "/xyz/" } { if {[string tolower [HTTP::uri]] contains "/xyz"}{ set uri [string range [HTTP::uri] 4 end] HTTP::uri $uri HTTP::header replace host "www.google.com" pool testGoogle log local0. "[IP::client_addr]:[TCP::client_port]: Replacing Host with http://[HTTP::host][HTTP::uri]" } } }
Presumably it doesn't rewrite the URI after the change because the host header of no longer matches 123abc.com. Why aren't you just using a redirect to
- Hariharan_Padm1
Nimbostratus
Hi Pete,
If I am redirecting to google, I am unable to rewrite the URL and also if we select some options like images or emails or any hyperlink, its showing the actual URL https://www.google.com/imghp?hl=en&tab=wi in the browser which we would like to prevent.
Thanks !
- PeteWhite
Employee
Presumably it does that because the new request comes in with a Host header of so it doesn't match your iRule. I think you need to go back to the drawing board to work out what you want it to do and the flow because you're going to struggle otherwise. You could rewrite the HTML coming through, or make sure you send them to a page on which they can't access specific links ie everything is relative.
- Hariharan_Padm1
Nimbostratus
Hi Pete,
Thanks for the suggestion ! Honestly I am new to irule configuration so I do not where to start and how to make it work but our ideal goal is to rewrite URL from internal to external website once its get redirected whatever we do, it should rewrite the URL information transparently without let the user know where they are actually getting redirected (Source URL). If you can give me some information, it would be appreciated. Thanks !
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