Forum Discussion
Phil_Rudich_735
Nimbostratus
Nov 07, 2007URI Rewrite
Hey all! I'm new to F5 and iRules and need some assistance.
Looking to take an original URL and perform a rewrite to another site so that the client does not know the true URL address. This is what I have so far:
when HTTP_REQUEST {
switch [HTTP::host] {
"www.yyy.mycompany.com" {
HTTP::header replace "Host" "zzz.mycompany.com"
HTTP::uri "/AAEP/"
}
}
}
However, there are two issues that I'm running into with this code:
Upon the first hit in the browser, it comes up with "Page cannot be displayed" error. Once I refresh, it works... but the other issue is that the graphics on the page do not display correctly.
Any help for this novice would greatly be appreciated!!
Thanks,
Phil
6 Replies
- The main issue I can see is that you are rewriting ALL uri's to "/AAEP/". All requests into the site (including image requests) will be rewritten.
http://www.yyy.mycompany.com/ -> http://zzz.mycompany.com/AAEP/
when HTTP_REQUEST { switch [HTTP::host] { "www.yyy.mycompany.com" { HTTP::header replace "Host" "zzz.mycompany.com" switch -glob [HTTP::uri] { "/" - "/index.html" - "/default.aspx" { HTTP::uri "/AAEP/" } } } } }
when HTTP_REQUEST { if { [HTTP::host] equals "www.yyy.mycompany.com" } { HTTP::header replace "Host" "zzz.mycompany.com" switch -glob [HTTP::uri] { "/" - "/index.html" - "/default.aspx" { HTTP::uri "/AAEP/" } } } }
- Phil_Rudich_735
Nimbostratus
Thanks for the response Joe.when HTTP_REQUEST { if { [HTTP::host] equals "wwwcert.abms.benelogic.com"} { HTTP::header replace "Host" "memberc06.benelogic.com" switch -glob [HTTP::uri] { "/" - "images/" - "bin/" { HTTP::uri "/AAEP/" } } } }
- You are still rewriting all URIs to "/AEEP/"
http://www.cert.abms.benelogic.com/ -> http://memberc06.benelogic.com/AAEP/
Host: wwwcert.abms.benelogic.com -> memberc06.benelogic.com
when HTTP_REQUEST { if { [HTTP::host] equals "wwwcert.abms.benelogic.com"} { HTTP::header replace "Host" "memberc06.benelogic.com" switch -glob [HTTP::uri] { "/" - "/images/*" - "/bin/*" { HTTP::uri "/AAEP[HTTP::uri]" } } } }
- Phil_Rudich_735
Nimbostratus
You are a genius Joe! That worked!! Looked like I was just missing the * wildcard from the code. (And yes, those were the only two directories - good call). - Deb_Allen_18Historic F5 AccountTo be honest, the most common cause for that is because there are 2 servers in the pool, but 1 is not responding (and not marked down by an appropriate monitor).
- Phil_Rudich_735
Nimbostratus
Thanks Deb, you rule... that was exactly the issue... I had 2 servers in the pool and one was not in use.
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects