Forum Discussion
OMA67
Sep 28, 2023Nimbostratus
F5 ADC - url rewrite redirect with parsing
F5 ADC - url rewrite redirect with parsing Hello, I would like to rewrite/redirect a url with parsing a part of old url into the new one Vocabulary : The Siret number is used to identify geographi...
- Sep 28, 2023
Not tested:
when HTTP_REQUEST { # Capture the URI from the HTTP request set uri [HTTP::uri] # Define the pattern to extract "uniqueid" using Regular Expression # The pattern now captures only numerical characters after the last hypen ("-") set pattern {.*-(\d+)$} # Apply the regular expression to capture "uniqueid" if {[regexp $pattern $uri ignore uniqueid]} { # Create the new URI by appending the captured "uniqueid" set new_uri "/newpath/subpath/$uniqueid" # Perform HTTP redirect to the new URI HTTP::redirect "https://mywebsite.com$new_uri" } }
lnxgeek
MVP
Not tested:
when HTTP_REQUEST {
# Capture the URI from the HTTP request
set uri [HTTP::uri]
# Define the pattern to extract "uniqueid" using Regular Expression
# The pattern now captures only numerical characters after the last hypen ("-")
set pattern {.*-(\d+)$}
# Apply the regular expression to capture "uniqueid"
if {[regexp $pattern $uri ignore uniqueid]} {
# Create the new URI by appending the captured "uniqueid"
set new_uri "/newpath/subpath/$uniqueid"
# Perform HTTP redirect to the new URI
HTTP::redirect "https://mywebsite.com$new_uri"
}
}
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