Forum Discussion
greenasp_41938
Nimbostratus
Aug 11, 2009Redirect url by subfolder
We currently have a domain that points to a set of servers (www.abc.com), however, we have a new requirement to have certain sub directories (not all) point to another set of servers. (i.e.- www.abc.com needs to point to the original set of servers and www.abc.com/content needs to be routed to our new set of servers. I am not sure how to create the irule to do this.
- That can be done in several ways. By a "set of servers", I assume you are referring to a "pool" in BIG-IP terminology. If this is the case, a simple iRule that inspects the URI can change the pool the connection is going to. Something like this:
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/content*" { pool pool_1 } "/othercontent*" { pool pool_2 } default { pool pool_default } } }
- greenasp_41938
Nimbostratus
Sorry, but I am new to f5. What you provided is great. To be a little more specific this is what I am trying to do. - dennypayne
Employee
It looks like Joe's code is still the way to go, you just need to substitute the correct pool names and make an exception for /content/media.when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/content/media*" { pool original_pool } "/content*" { pool new_content } default { pool original_pool } } }
- dennypayne
Employee
Unless you are saying that /about-us, /answers, etc all need to be sent to the new pool as well. Then those would need to be added to the switch in the same manner as I've done for /content* above. - greenasp_41938
Nimbostratus
yes, they need to be set to the new pool as well. - Colin_Walker_12Historic F5 AccountSo if you want /content/media to go to the original pool, your above list to all go to the new pool, and everything else to go to the original pool, then you want something like this:
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/content/media*" { pool original_pool } "/about-us*" - "/answers*" - "/logs*" - "/state*" - "/press*" - "/admin*" - "/users*" - "/node*" - "/content*" { pool new_content } default { pool original_pool } } }
- greenasp_41938
Nimbostratus
I can't seem to get it to redirect. To test I created a www.abc.com/test/test-page on the new drupal server. I then entered the following irule to test. - dennypayne
Employee
www.abc.com is not part of the URI. It is the hostname (HTTP::host), so [HTTP::uri] will never match "http://www.abc.com/test". The URI is just /test. - greenasp_41938
Nimbostratus
no, I tried it with the /test* first and it do not route it, so I thought that would help.
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