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...
Stefan_Klotz
Cumulonimbus
Nov 19, 2013Hi Paul,
if you have the list already as an Excelsheet, then a Data Group List should be your best friend. Is the hostname of your 404-URLs always the same, means do you have just 300+ different URIs or do you have several different DNS-names pointing to the same VIP? In Excel you have to put together your first two columns with the following command (in C1):=CONCATENATE("""";A1;" ";B1;"""")
Then create a DGL from type string and leave it empty.
Connect via SSH to your BIG-IP and edit your conf-file:
pico bigip.conf
Search for your created DGL by pressing Strg+W and enter "class [name of your DGL]" (without quotes). You should find something like this (sorry can't use curly brace):
class [name of your DGL] (
type string
)
Replace it with (sorry can't use curly brace):
class [name of your DGL] (
(
[insert here your block from column C from your Excelsheet]
)
)
Save your changes with Strg+O and exit with Strg+X.
Verify your changes with (v10.x):
b verify load
And activate it with (v10.x):
b load
Assuming in column A is just the URI and in column B the redirect URL like in below example:
A1=/path1/file.html
B1=http://new.site.com/redirect
you can create an iRule similar like this (v10.x, sorry can't use curly brace):
when HTTP_REQUEST (
set redirect_url [findclass [HTTP::uri] [name of your DGL] " "]
if ( $redirect_url != "" ) (
HTTP::respond 301 Location "$redirect_url"
)
)
You can also work with external files as Data Group List, but I didn't have the correct iRule commands in mind right now (same as for v11.x as findclass is not valid there anymore).
This is also not tested, but should point you in the right direction.
Ciao Stefan 🙂
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