Forum Discussion
Paul_Jenkins_12
Nimbostratus
Nov 19, 2013Lots of specific URLs to 301 redirect - best approach?
I have a lot of specific URLs that are currently returning 404s that I need to 301 redirect to specific new locations (about 300+). The data is in an excel file with URL404 and URLNew as the columns...
Magnum_IP
Nimbostratus
Nov 19, 2013Paul,
Yes, a data group and short iRule would be perfect for this.
Create a string data group, for the purposes of this example, called datagroup_redirects. The String would be the url you want to match on and the Value would be the url you want to redirect to. So the entries would look something like...
www.domain.com/if/this/is/requested := http://www.domain.com/redirect/to/here
The code to perform the redirect would be something like...
when HTTP_REQUEST {
if { [class lookup [HTTP::host][HTTP::uri] datagroup_redirects] ne "" } {
HTTP::respond 301 Location [class lookup [HTTP::host][HTTP::uri] [datagroup_redirects]
}
}
Attach the iRule to the appropriate Virtual Server.
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