Forum Discussion
lchln_304378
Dec 29, 2016Nimbostratus
Translate mod_rewrite to iRules
Hi guys,
Trying to migrate mod_rewrite rules to F5 iRules and am not having much success. The current setup uses a regex to get the subdomain from a HTTP_HOST and then rewrites the URL, appending t...
JG
Jan 04, 2017Cumulonimbus
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] ends_with ".domain.com" } {
switch -glob [string tolower [HTTP::uri]] {
"/lib/*" {
HTTP::redirect "http://my-error-page-server/"
}
"/static_pages/*" {
HTTP::redirect "http://my-error-page-server/"
}
"/assets/*" {
HTTP::redirect "http://my-error-page-server/"
}
default {
HTTP::header replace Host "[getfield [HTTP::host] '.' 2].[getfield [HTTP::host] '.' 3]"
HTTP::uri "/[getfield [HTTP::host] '.' 1]"
node 1.2.3.4 Your backend server.
}
}
}
}
If this does not work, please forget the irule for a moment and write down a full description of you requirement, for we seem to be trying to hit a moving target.
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