Forum Discussion
301 Redirect Using Data Group External File
This should be easy...and I see some posts on it, but I can't seem to get it to work.
We were given a list of hundreds of URL's that need 301 redirects. The host and URI in most cases is entirely different and unique so I can't just wildcard a redirect for everything to a single destination.
example:
https://oldsite.com/pdf/111 --> http://newsite.com/doc/222 https://oldsite.com/jpg/222 --> http://newsite.com/bmp/111
etc.
I have all of the old site to new site mappings and I read another post that said I should create an external data group as a string that has := as the separator, so I have a datagroup called "testuri" and it looks like this:
"; := ";
And I have an irule that says:
when HTTP_REQUEST {
if {[set code_url [class match -value -- [string tolower [HTTP::host][HTTP::uri]] equals testuri]] ne ""}{
HTTP::respond [getfield code_url " " 1] Location [getfield code_url " " 2]
}
}
...but it doesn't work.
In the end all I need is an irule that looks for the inbound request and if it's in the data group then returns the new value that it should be mapped to.
This seems simple, but it's turning not to be as simple as I had hoped.
- Faruk_AYDINNimbostratus
Hi Guy,
Your
command cannot hit any item in the data group. Because the item equalsclass match
but your command searcheshttps://test.randomdomain.com/
in other word[HTTP::host][HTTP::uri]
. Therefore, deletetest.randomdomain.com/
at the beginning of the item in the data group.https://
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