Forum Discussion
brent112_11716
Nimbostratus
May 02, 2012Rewrite a portion of URI
Is there an easy way to re-write only a portion of the URI? Say i want to turn this.
http://sharepoint/Information Technology/Information Technology Internal/projects/11111/default.aspx
to
http://sharepoint/IT/ITI/projects/11111/default.aspx
I only want to re-write the "Information Technology/Information Technology Internal" to
"IT/ITI" and keep everything after portion of the URI in place, is this even possible?
Thanks,
Brent
3 Replies
- MiLK_MaN
Nimbostratus
Hi,
If you want to simply rewrite the URI, you can do the following:
when HTTP_REQUEST {
if { [set path [findstr [HTTP::uri] "/Information Technology/Information Technology Internal" 56]] ne "" } {
HTTP::uri "/IT/ITI/$path"
}
} - brent112_11716
Nimbostratus
So what does your example actually do? I am not sure what the 56 and "ne" are for? Does it set the $path variable to anything after the "/Information Technology/Information Technlogy Internal" and then rewrite the URI with the "IT/ITI" and the path variable appended to it?Thanks for the help. I am new to irules.
- MiLK_MaN
Nimbostratus
The findstr command allows you to look for something within a string, then you can issue a skip count which in this case is 56. This means the variable "path" is being stored with everything after "/Information Technology/Information Technology Internal/".
The HTTP::uri command then modifies what is sent to the backend server.The "ne" just means "not equal to", so if the set statement returns nothing, it won't execute the above HTTP::uri command.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
