Forum Discussion
URL Redirection IRule
- Dec 09, 2016
Hi Dishant, you can try this:
(Thanks to Stanislas - using respond, relative path and not use string to lower in case its not necessary)
when HTTP_REQUEST { if { (([string tolower [HTTP::host]] contains "www.pitneybowes.us") and ([HTTP::uri] equals "/shop/ink-and-supplies/postage-meter-ink-and-supplies/for-dm100i-dm125-dm225/en-us/storeus")) { HTTP::respond 301 noserver Location "/shop/ink-and-supplies/postage-meter-ink-supplies/for-dm-series/en-us/storeus" } }
Hi Dishant, you can try this:
(Thanks to Stanislas - using respond, relative path and not use string to lower in case its not necessary)
when HTTP_REQUEST {
if { (([string tolower [HTTP::host]] contains "www.pitneybowes.us") and ([HTTP::uri] equals "/shop/ink-and-supplies/postage-meter-ink-and-supplies/for-dm100i-dm125-dm225/en-us/storeus")) {
HTTP::respond 301 noserver Location "/shop/ink-and-supplies/postage-meter-ink-supplies/for-dm-series/en-us/storeus"
}
}
Hi,
Please never include protocol and hostname in HTTP redirect if target service is the same as source service...
As the source URL is hosted on hostname and service is HTTPS, redirect to relative URL and not absolute.
Most of F5 rewrite issues are caused because developers still insert full path instead of relative path when it is useless.
And the redirect with 301 response code is a better solution than 302 (default with HTTP::redirect) to redirect permanently an URL to another.
So, replace the line
HTTP::redirect "https://www.pitneybowes.us/shop/ink-and-supplies/postage-meter-ink-supplies/for-dm-series/en-us/storeus"
by
HTTP::respond 301 noserver Location "/shop/ink-and-supplies/postage-meter-ink-supplies/for-dm-series/en-us/storeus"
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