Forum Discussion
Need an iRule to redirect site http://mysite/projects/test for redirect to http://mysite/sites/testforredirect
We are moving an internal site to a new area
But it isn't quite that simple. I've created the following that will work (partially)
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/projects/test for redirect/" } {HTTP::redirect http://[HTTP::host]/sites/testforredirect} }
The problem is if someone has bookmarked a location for instance for redirect/shared documents/document1. It needs to go to documents/document1. But it would be redirected to without going to the specific location the user needs
Any ideas on how to get the end part of the uri to append to the URL?
4 Replies
- nitass
Employee
the problem is if someone has bookmarked a location for instance for redirect/shared documents/document1. It needs to go to documents/document1.
e.g.
configuration [root@ve11a:Active:In Sync] config tmsh list ltm virtual bar ltm virtual bar { destination 172.28.24.10:80 ip-protocol tcp mask 255.255.255.255 pool foo profiles { http { } tcp { } } rules { qux } source 0.0.0.0/0 source-address-translation { type automap } vs-index 19 } [root@ve11a:Active:In Sync] config tmsh list ltm rule qux ltm rule qux { when HTTP_REQUEST { if { [HTTP::uri] starts_with "/projects/test_for_redirect/" } { set newuri [string map {/projects/test_for_redirect/ /sites/testforredirect/} [HTTP::uri]] HTTP::redirect "http://[HTTP::host]$newuri" } } } test [root@ve11a:Active:In Sync] config curl -I http://172.28.24.10/projects/test_for_redirect/shared_documents/document1 HTTP/1.0 302 Found Location: http://172.28.24.10/sites/testforredirect/shared_documents/document1 Server: BigIP Connection: Keep-Alive Content-Length: 0- Roland_Hansen_1
Nimbostratus
Not perfect but it definitely pointed me in the right direction. The problem is that most users put in the URL as something like http://mysite/projects/Test For Redirect with spaces and a mixture of capital and lower case letters. Here is the ultimate solution I came up with due to your excellent suggestion. when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/projects/test%20for%20redirect" } { set newuri [string tolower [string map {/projects/test%20for%20redirect /sites/testforredirect} [HTTP::uri]]] HTTP::redirect "http://[HTTP::host]$newuri" } }
- nitass_89166
Noctilucent
the problem is if someone has bookmarked a location for instance for redirect/shared documents/document1. It needs to go to documents/document1.
e.g.
configuration [root@ve11a:Active:In Sync] config tmsh list ltm virtual bar ltm virtual bar { destination 172.28.24.10:80 ip-protocol tcp mask 255.255.255.255 pool foo profiles { http { } tcp { } } rules { qux } source 0.0.0.0/0 source-address-translation { type automap } vs-index 19 } [root@ve11a:Active:In Sync] config tmsh list ltm rule qux ltm rule qux { when HTTP_REQUEST { if { [HTTP::uri] starts_with "/projects/test_for_redirect/" } { set newuri [string map {/projects/test_for_redirect/ /sites/testforredirect/} [HTTP::uri]] HTTP::redirect "http://[HTTP::host]$newuri" } } } test [root@ve11a:Active:In Sync] config curl -I http://172.28.24.10/projects/test_for_redirect/shared_documents/document1 HTTP/1.0 302 Found Location: http://172.28.24.10/sites/testforredirect/shared_documents/document1 Server: BigIP Connection: Keep-Alive Content-Length: 0- Roland_Hansen_1
Nimbostratus
Not perfect but it definitely pointed me in the right direction. The problem is that most users put in the URL as something like http://mysite/projects/Test For Redirect with spaces and a mixture of capital and lower case letters. Here is the ultimate solution I came up with due to your excellent suggestion. when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/projects/test%20for%20redirect" } { set newuri [string tolower [string map {/projects/test%20for%20redirect /sites/testforredirect} [HTTP::uri]]] HTTP::redirect "http://[HTTP::host]$newuri" } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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