Forum Discussion
destr0yr_22001
Nimbostratus
Apr 13, 2012rewrite url with /en/foo to /foo
Hi, I'd like to rewrite a number of urls from: www.abc.com/foo/meh/ www.abc.com/foo/bar/ www.abc.com/foo/rar/ to: www.abc.com/meh/ www.abc.com/bar/ www.abc.com/...
hoolio
Cirrostratus
Apr 13, 2012Hi,
I think this should work to strip off the first directory for URIs starting with /foo/. HTTP::path will allow you to rewrite the path as opposed to HTTP::redirect which sends a 302 redirect and updates the URL the client sees.
when HTTP_REQUEST {
Check the HTTP path with wildcards
switch -glob -- [HTTP::path] {
"/foo/*" {
Remove /foo from the path by skipping one character and matching after the next /
HTTP::path [findstr [HTTP::path] / 1]
}
}
}
Aaron
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