Redirect does not include file in uri

I’m trying to create a profile or Irule to redirect links from a dead site to another site.

Old:

New:

I was able to create a profile that changes the host name and changes the path from /forms/pdf to /Dir%20PDF. The profile also redirects to https. The redirect works but the pdf filename is not part of the redirect. I have not been able to determine why.

Care to share the rule you created?

The below should work if I understood you right…Again Jie helped me the other day so I would wait for his input as well..

when HTTP_REQUEST {
if { [string tolower [HTTP::host]] eq "oldsite" } and ([string tolower [HTTP::uri]] contains "/forms/pdf/somepdf.pdf") } {
        HTTP::redirect "https://newsite/Dir%20PDF/somepdf.pdf"
else { use pool default_pool
    }
}

where default_pool would be your existing pool on that vip.

I was able to figure it out.

when HTTP_REQUEST { if { [string tolower [HTTP::host]] eq “oldserver” and [string tolower [HTTP::path]] starts_with “/forms/pdf”} { set file [string range [HTTP::uri] 11 end] HTTP::respond 302 location “$file” } }

You can use following code to get file name

when HTTP_REQUEST { 
    if { [string tolower [HTTP::host]] eq "oldserver" and [string tolower [HTTP::path]] starts_with "/forms/pdf"} {     
        HTTP::respond 302 location "https://newserver[string map {"/forms/pdf/" "/oldserver%20PDF/"} [HTTP::uri]]"
    } 
}