F5 is upgrading its customer support chat feature on My.F5.com. Chat support will be unavailable from 6am-10am PST on 1/20/26. Refer to K000159584 for details.

Forum Discussion

VOLA_144433's avatar
VOLA_144433
Icon for Nimbostratus rankNimbostratus
Oct 23, 2014

Simple URL rewriting

Hello, I'm a newbie in F5 ... My pb is very simple I guess but I cannot find the right method, redirect ou rewriting ? here it is, I need to change a URL call from http://HOST/toto/api/ -> http://HOST/toto/soapapi/

 

it looks pretty simple indeed. I've tried to set a Profiles Services Rewrite

 

Thanks for your help

 

10 Replies

  • Hi,

     

    Will all requests use this newest URI ?

     

    Just to be sure that you need redirect instead of rewriting.

     

  • Hello Yes all requests will use the new URI (API change)

     

    I guess a rewriting is cleaner here isn't it ?

     

    Thanks

     

  • You can do both, it depends only on what you want to publish.

     

    Remember that the cleanest way might be to redirect users as you're iRule won't be process more than one time for each connection.

     

    Tell us what you want, or I'll give you an example for each and you'll choose.

     

  • Thank you Thomas

     

    The URL I want to rewrite or to redirect is a technical URL. Users won't be impacted but only webservices requests.

     

    An application is requesting a service at http://host/alfresco/api/... (hard coded)

     

    After an upgrade of that webservice the URL is now /alfresco/soapapi/

     

    The thing is I do not know what is after /api/ the page and the variables. I just know they are the same.

     

    So I just need to replace api by soapapi

     

    Hope it's clear. Guillaume

     

  • If it's about web services, the best solution is to rewrite URI I think.

    Does your URI condition is /api or /alfresco/api ?

    Here is the iRule for /api condition :

    when HTTP_REQUEST {
        if { [string tolower [HTTP::uri]] starts_with "/api" } {
            set uri [string map -nocase {"/api" "/soapapi"} [HTTP::uri]]
            HTTP::uri $uri
        }
    }
    
  • The URL condition is /alfresco/api

     

    Do you think I could do the same with LT Policy ?

     

    Target: http-uri / Event: Request / Action: Replace / parameters: value = /alfresco/soapapi/

     

    Thanks

     

  • Yes you can do the same with LTM policies, but be careful you have to define your values otherwise it will replace everything.

     

    If you define / condition, /alfresco/api for example won't match.

     

  • I see ... the condition should be "start_with /alfresco/api/"

     

    what do you mean by values ?

     

    In fact the client is requesting several soap services at /alfresco/api/AuthenticationService or at /alfresco/api/DirectoryService or at an other service.

     

    How can I manage the replace ?

     

    Thanks G.

     

  • Yes you're right, you have to use starts_with condition.

     

    I meant by values to fill in this condition, as you wrote / condition in your last post.

     

  • hello

     

    Just for information its also possible to use Profile Rewrite

     

    Both

     

    Client URI = http://ged.int.mars/alfresco/api/

     

    Server URI = http://ged.int.mars/alfresco/soapapi/

     

    Thanks Guillaume