Forum Discussion
What's the best approach for an http:redirect with exceptions?
Hey guys,
We're going to move a SharePoint site and all its subsites to a new location in our SharePoint farm. I need to create new iRule to redirect all users to the new site except for one particular subiste. I have written the following iRule but I 'm not sure whether this is the most efficient way to proceed. Would you mind having a look and let me know if there's a better way to handle this?
TIA
Let's say I want ot redirect all requests for https://intranet.company.com/my_old_site to https://intranet.company.com/my_new_site except when it's a request for https://intranet.company.com/my_old_site/subsite_we_need_to_keep?
when HTTP_REQUEST {
Check if path starts with /my_old_site/
if {
[string tolower [HTTP::path]] starts_with "/my_old_site" &&
[string tolower [HTTP::path]] not (starts_with "/my_old_site/subsite_we_need_to_keep")} then {
Modify HTTP::path to replace original request
HTTP::redirect [string map {/my_old_site /my_new_site} [HTTP::path]]
}
}
2 Replies
- Vijay_E
Cirrus
Looks good. May be use a variable:
when HTTP_REQUEST { set PATH [string tolower [HTTP::path]] Check if path starts with /my_old_site/ if { $PATH starts_with "/my_old_site" && $PATH not (starts_with "/my_old_site/subsite_we_need_to_keep")} { Modify HTTP::path to replace original request HTTP::redirect [string map {/my_old_site /my_new_site} [HTTP::path]] } } thanks for your reply. This is the final working version of my iRule
when HTTP_REQUEST { set PATH [string tolower [HTTP::path]] Check if path starts with /my_old_site/ if {($PATH starts_with "/my_old_site") and not ($PATH starts_with "/my_old_site/subsite_we_need_to_keep")} then { Modify HTTP::path to replace original request with new address HTTP::redirect [string map {my_old_site /my_new_site} [HTTP::path]] } }
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
