Forum Discussion

siru_129409's avatar
siru_129409
Icon for Nimbostratus rankNimbostratus
Sep 21, 2015

url rewriting/redirection

Hi all

 

I Have a query on URL rewriting/redirection, I have two scenarios as explained below

 

Scenario 1

users type www.abc.com on browser and We have hosted the site internally as www.xyz.com/abc Can the users get the url like www.abc.com instead of the hosted header?

 

Scenario 2

Some users type Arabic character on browser like اختبار We hosted the site internally as www.xyz.com Can the users get the url like www.اختبار instead of the hosted header ?

 

Does F5 can Recognize any language other than English ?

 

Any help would be highly appreciated. Thanks!

 

7 Replies

  • Hi!

    Giving this a go:

    If you want to host site www.xyz.com as www.abc.com you can replace the host header on the way in and use a stream profile to replace links with xyz.com with abc.com:

    when HTTP_REQUEST {
         Disable the stream filter for requests
        STREAM::disable
    
         Remove this header to prevent server from compression response
        HTTP::header remove Accept-Encoding
    
        Replace the host header to match www.xyz.com
        HTTP::header replace "Host" "www.xyz.com"
    }
    
    when HTTP_RESPONSE {
         Rewrite the Location header for redirects 
        if { [HTTP::header exists Location] }{ 
            HTTP::header replace Location [string map {"https://www.xyz.com" "https://www.abc.com"} [HTTP::header Location]] 
        } 
    
         Rewrite the response content using a stream profile if it is text 
        if { [HTTP::header Content-Type] contains "text" } { 
    
             Set the stream expression with the find/replace strings 
            STREAM::expression "@www.xyz.com@www.abc.com@" 
    
             Enable the stream filter 
            STREAM::enable
        } 
    } 
    

    Scenario 2:

    Haven't worked with arabic at all, but I think you can use IDN formatting to achieve that.

    Check out this site: http://mct.verisign-grs.com/convertServlet?input=www.%D8%A7%D8%AE%D8%AA%D8%A8%D8%A7%D8%B1

    /Patrik

  • Hi Patrik jonsson, In the scenario 1, I have to add one more thing.. The user type www.abc.com the corresponding internally hosted site is www.xyz.com\abc and user should see www.abc.com on the browser instead of www.xyz.com\abc (as explained before) And there is another set of users, they will type www.def.com the corresponding internally hosted site is www.xyz.com\def and users should see www.def.com on the browser instead of www.xyz.com\def

     

    Similarly I have to publish eight sites, what changes I have to do in the above irule in order to achieving the same. your help will be highly appreciated.

     

  • Hi Siru!

    Let's say a user enters www.abc.com and ends up at www.xyz.com/abc. How will you handle the links?

    If what you describe is all you want this rule might work:

    when HTTP_REQUEST {
    
        Get the middle part of the host
        set site [lindex [split [HTTP::host] "."] end-1]
    
        Concatenate midhost to the uri
        HTTP::uri "$site/[HTTP::uri]"
    
         Disable the stream filter for requests
        STREAM::disable
    
         Remove this header to prevent server from compression response
        HTTP::header remove Accept-Encoding
    
        Replace the host header to match www.xyz.com
        HTTP::header replace "Host" "www.xyz.com"
    }
    
    when HTTP_RESPONSE {
         Rewrite the Location header for redirects 
        if { [HTTP::header exists Location] }{ 
            HTTP::header replace Location [string map {"https://www.xyz.com" "https://www.abc.com"} [HTTP::header Location]] 
        } 
    
         Rewrite the response content using a stream profile if it is text 
        if { [HTTP::header Content-Type] contains "text" } { 
    
             Set the stream expression with the find/replace strings 
            STREAM::expression "@www.xyz.com@www.abc.com@" 
    
             Enable the stream filter 
            STREAM::enable
        } 
    } 
    

    Please note that I have not tested these rules. That's something you need to do yourself. 🙂

    /Patrik

  • There was a typo in my rule and devcentral does not allow me to edit it, so here's the updated rule:

    when HTTP_REQUEST {
    
        Get the middle part of the host
        set site [lindex [split [HTTP::host] "."] end-1]
    
        Concatenate midhost to the uri
        HTTP::uri "/$site/[HTTP::uri]"
    
         Disable the stream filter for requests
        STREAM::disable
    
         Remove this header to prevent server from compression response
        HTTP::header remove Accept-Encoding
    
        Replace the host header to match www.xyz.com
        HTTP::header replace "Host" "www.xyz.com"
    }
    
    when HTTP_RESPONSE {
         Rewrite the Location header for redirects 
        if { [HTTP::header exists Location] }{ 
            HTTP::header replace Location [string map {"https://www.xyz.com" "https://www.abc.com"} [HTTP::header Location]] 
        } 
    
         Rewrite the response content using a stream profile if it is text 
        if { [HTTP::header Content-Type] contains "text" } { 
    
             Set the stream expression with the find/replace strings 
            STREAM::expression "@www.xyz.com@www.abc.com@" 
    
             Enable the stream filter 
            STREAM::enable
        } 
    } 
    

    /Patrik