Forum Discussion

mohdemraan_1691's avatar
mohdemraan_1691
Icon for Nimbostratus rankNimbostratus
Sep 05, 2014

Need to retain case sensitive in uri

Hi All,

 

I have a request to retain case sensitive in uri path like this: http://mysite.com/ThisFolderPath/v1

 

if someone may try something like this: http://mysite.com/thisfolderpath/v1 then it should need to be redirected to my URL which case sensitive. also the v in second uri should be in small.

 

can someone help please ?

 

2 Replies

  • not sure if i understand correctly. is it something like this?

     config
    
    [root@ve11a:Active:In Sync] config  tmsh list ltm rule qux
    ltm rule qux {
        when RULE_INIT {
      set static::uri "/ThisFolderPath/v1"
    }
    when HTTP_REQUEST {
      if { [string match -nocase $static::uri [HTTP::uri]] } {
        if { [HTTP::uri] ne $static::uri } {
          HTTP::redirect "http://mysite.com${static::uri}"
        }
      }
    }
    }
    
     test
    
    [root@ve11a:Active:In Sync] config  curl -I http://172.28.24.10/thisfolderpath/v1
    HTTP/1.0 302 Found
    Location: http://mysite.com/ThisFolderPath/v1
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    [root@ve11a:Active:In Sync] config  curl -I http://172.28.24.10/THISfolderpath/v1
    HTTP/1.0 302 Found
    Location: http://mysite.com/ThisFolderPath/v1
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    [root@ve11a:Active:In Sync] config  curl -I http://172.28.24.10/ThisFolderPath/v1
    HTTP/1.1 404 Not Found
    Date: Fri, 05 Sep 2014 14:53:01 GMT
    Server: Apache/2.2.3 (CentOS)
    Last-Modified: Sun, 09 Feb 2014 08:39:51 GMT
    ETag: "41879c-59-2a9c23c0"
    Accept-Ranges: bytes
    Content-Length: 89
    Content-Type: text/html; charset=UTF-8
    
    
  • The HTTP::uri command is case sensitive, so you could very simply do something like this:

    when HTTP_REQUEST {
        if { [HTTP::uri] ne "/ThisFolderPath/v1" } {
            HTTP::redirect "http://[HTTP::host]/ThisFolderPath/v1"
        }
    }