Forum Discussion
URL Redirection IRule
Can i get the Irule for redirection of https://www.pitneybowes.us/shop/ink-and-supplies/postage-meter-ink-and-supplies/for-dm100i-dm125-dm225/en-us/storeus to https://www.pitneybowes.us/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" } }
- Stanislas_Piro2Cumulonimbus
Hi,
try this:
when HTTP_REQUEST { if { [HTTP::host] equals "www.pitneybowes.us" && [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" } }
- Dvirus_297774Altocumulus
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" } }
- Stanislas_Piro2Cumulonimbus
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