Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Redirect all URLS's from one domain to another domain with same subdomain

Ayush07
Altostratus
Altostratus

Hi All,

Looking for Irule to redirect all URLS from *.test.pmc.it.com to *.apps.dev2.co.it.com
where * can be anyting and only this * part will be same in both.

Thank you

 

4 REPLIES 4

Hi @Ayush07 , 
Follow this KB From F5 : 
https://support.f5.com/csp/article/K15117465
or check out the following  syntax it will give you a clue to implement your irule : 

when HTTP_REQUEST {
  if { [HTTP::host] eq "website1.com" } {
    HTTP::redirect https://websitesite2.com[HTTP::uri]
  }
}


If you could not perform it , I will try to simulate it in my lab later. 

_______________________
Regards
Mohamed Kansoh

Hi Mohamed,

Thanks, Given irule i already have on many VIP's, which is for individual URL redirection, but in this i am looking for redirection from *.test.pmc.it.com to *.apps.dev2.co.it.com, where * can be anything.

how would i catch * prefix coming in  .test.pmc.it.com and then put that value into redirect *.apps.dev2.co.it.com ?

for examples redirect a.test.pmc.it.com, b.test.pmc.it.com, c.test.pmc.it.com....and so on to a.apps.dev2.co.it.com, b.apps.dev2.co.it.com, c.apps.dev2.co.it.com..and so on. with URI path as well.

Hi @Ayush07 , 
Well, sorry for miss understanding. 
I have simulated your scenario in my lab and I achieved it. 
so look first at my lab environment and Check my script for your Environment : 
> My lab iRule : 
my_lab.PNG

and This is the iRule Result : 
Lab_result.PNG

where "shopping" is the Fixed part and I swapped the rest of host part , after that I redirected to new host.

> and now I have written this iRule to match your environment , in the same way I hope it works with you : 

 

when HTTP_REQUEST {
if {[HTTP::host] contains "test.pmc.it.com"} {
HTTP::host [string map {".test.pmc.it.com" ".apps.dev2.co.it.com"}[HTTP::host]]
HTTP::redirect https://[HTTP::host]
}
}

 

Try it and keep me updated

GoodLuck

_______________________
Regards
Mohamed Kansoh

Hi @Ayush07, did @Mohamed_Ahmed_Kansoh's second reply help you? If yes, make sure to click Accept as Solution so future users facing the same challenge can easily see the solution. 🙂