Forum Discussion
8 Replies
- Jad_Tabbara__J1Cirrostratus
Please explain more...
- DPIT_323803Nimbostratus
I want to rewrite a URL. No Redirect.
Thera are a list of url's that should rewrite to a single URL.
List:
Rewrite to: https://www.mainpage.de
Which version you're running on. If running on 11.5.x or above, use the rewrite profile:
- clientside : https://www.blah-test.com/
- serverside : https://www.mainpage.de/
else,
when HTTP_REQUEST { if { ([HTTP::host] equals "www.blah-test.com") } { HTTP::host [string map {www.blah-test.com www.mainpage.de} [HTTP:host]] } } when HTTP_RESPONSE { if { [HTTP::header values Location] contains "www.mainpage.de" } { HTTP::header replace Location [string map {www.mainpage.de www.blah-test.com} [HTTP::header value Location]] } }
- DPIT_323803Nimbostratus
Hi Gents,
I have put this to the VS at clientside.
Code when HTTP_REQUEST { set host [string tolower [HTTP::host]] switch $host { "; - "; - "; { HTTP::redirect "; } } }
But I don't know where to put the following response on serverside.
when HTTP_RESPONSE { if { [HTTP::header values Location] contains "; } { HTTP::header replace Location [string map { } [HTTP::header value Location]] } }
Can you tell me where to put the serverside irule?
Thanks DPIT
- Habib_Ulla_KhanNimbostratus
You can consolidate both irules into one and apply on same VIP.
As said by Habib, that is 1 single rules working on different events. You should start learning Irule basics.
Hi DPIT,
I want to rewrite a URL. No Redirect.
Having multiple external site names pointing to the same web content will hurt your SEO rating and will make your life little more complicated in 99 out of 100 cases.
Redirecting your redundant external site names (via HTTP-Status 301 or 307) to a single and common location from where the content is finaly delivered in a unified way will on the other hand boost your SEO ratings. Beside of this, redirecting is a less complicated approach compared to rewriting every single HTTP request and/or HTTP response.
Cheers, Kai
- jurgenvdmark_14Nimbostratus
Instead of using an iRule this can also be achieved by a ltm policy, which you assign to the virtual. Ltm policies are more visually then iRules. Look at: https://devcentral.f5.com/articles/ltm-policy for more details about ltm policies
See below for an example:
ltm policy redirect_policy { controls { request-adaptation } requires { http } rules { redirect_to_mainpage.de { actions { 0 { http-host replace value www.mainpage.de } } conditions { 0 { http-host values { www.blah-test.com www.blahtest.com www.blahtest.de } } } ordinal 1 } } strategy first-match } ltm virtual test { destination 1.2.3.4:https ip-protocol tcp mask 255.255.255.255 policies { redirect_policy { } } profiles { clientssl { context clientside } http { } requestadapt { context clientside } tcp { } } }