Forum Discussion

DenisG_22372's avatar
DenisG_22372
Historic F5 Account
Mar 25, 2012

HTTP rewriting problems, realtive path hell.

I need some rewriting rules so that if a user enters in just http://server it will redirect to http://server/application/application, with images coming from http://server/application and spellcheck from http://server/spellcheck.

 

 

unfortunately every call coming in is getting the /application appended so the spell check doesn't work. Logic is not working today.

 

 

 

I thought I would just use an if / else, but the spellcheck is killing that option. Here is what I have so far:

 

 

 

when HTTP_REQUEST {

 

set host [string tolower [HTTP::host]]

 

set path [HTTP::path]

 

 

if { ( $host ne "server.domain.com" ) } {

 

HTTP::redirect " server.domain.com $path"

 

}

 

if { ([HTTP::uri] equals "/" or [HTTP::uri] equals "/application" )} {

 

HTTP::uri /application/application

 

}

 

this is the broken bits

 

if {([HTTP::uri] starts_with "/jspellhtml2k4")} {

 

HTTP::uri /spellcheck[HTTP::uri]

 

}

 

 

if { !([HTTP::uri] starts_with "/application")} {

 

HTTP::uri /application[HTTP::uri]

 

}

 

}

 

 

 

 

 

2 Replies

  • Hi Denis,

    Can you try this version with debug logging added? If it doesn't work, can you reply with the anonymized logs from /var/log/ltm?

    
    when HTTP_REQUEST {
    
    if { [string tolower [HTTP::host]] ne "server.domain.com" } {
    
    HTTP::redirect "http://server.domain.com[HTTP::uri]"
    log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting to http://server.domain.com[HTTP::uri]"
    
    } else {
     Check requested path
    switch -glob [HTTP::uri] {
    "/" -
    "/application" {
    HTTP::uri /application/application
    log local0. "[IP::client_addr]:[TCP::client_port]: Rewriting [HTTP::uri] to /application/application"
    }
    "/jspellhtml2k4*" {
    HTTP::uri /spellcheck[HTTP::uri]
    log local0. "[IP::client_addr]:[TCP::client_port]: Rewriting [HTTP::uri] to /spellcheck[HTTP::uri]"
    }
    "/application*" {
     Do nothing
    log local0. "[IP::client_addr]:[TCP::client_port]: Preserving [HTTP::uri]"
    }
    default {
    HTTP::uri /application[HTTP::uri]
    log local0. "[IP::client_addr]:[TCP::client_port]: Rewriting [HTTP::uri] to /application[HTTP::uri]"
    }
    }
    }
    }
    

    Thanks, Aaron
  • DenisG_22372's avatar
    DenisG_22372
    Historic F5 Account
    A million thanks, I see that my newbiness in not see the wildcard * needed after the application* and the spellcheck*

     

     

    You have good logic, and I thank you.

     

     

    D