How to hide directory from URL site

MoratoMorato Member
edited November 2019 in aFleX

Hi!!

I'd like how I can hide the directory from the site as example bellow:

Site: http://site.com/index.php?page=items

But in the browser only show http://site.com/

Is that possible be configurated in A10?

Thanks,

Rafael Morato

Comments

  • jserranojserrano Member ✭✭

    Hi Rafael,

    You can try this aflex example to hide internal url path on your server and expose a diferent path to the internet:



    when HTTP_REQUEST {

    set url [string tolower [HTTP::uri]]

    if { $url starts_with "/external/url/"} {

     HTTP::uri "[string map { "/external/url/“ "/internal/url/" } [ HTTP::uri]]"

    }

    }

    when HTTP_RESPONSE {

    if { [HTTP::is_redirect] } {

     HTTP::header replace Location "[string map { "/internal/url/" "/external/url/" } [ HTTP::header Location]]"

    }

     HTTP::stream replace "/internal/url/" "/external/url/“


    }



    Hope this help!

    José Serrano

  • MoratoMorato Member

    Thank you José Serrano,

    I'm going to try that and report here if that works or not.


    Regards,

    Rafael Morato

  • MoratoMorato Member

    I've tried that script, but that didn't works.

    I tried to run that:

    when HTTP_RESPONSE {

      if { [HTTP::is_redirect] && [HTTP::header Location] contains "/cfcc/login/login.jsp" } {

    log local0. "Client [IP::client_addr] Rewriting from [HTTP::header Location]"

    HTTP::header replace Location [string map -nocase "/cfcc/login/login.jsp" [HTTP::header Location]]

    log local0. "Client [IP::client_addr] Rewritten to [HTTP::header Location]"

    }

    }

    I found that in others forums, but until now I dind't find any solution which help me to hide uri from the my url site.


    Regards,

    Rafael Morato

  • jserranojserrano Member ✭✭

    Hi Rafael,

    Checking your aFlex I see you´re only taking care of the server response and only in case of a redirect.

    Also you are missing the rewrite action on the string map options

    HTTP::header replace Location [string map -nocase {"/cfcc/login/login.jsp" "/"} [HTTP::header Location]]


    If you want to hide an internal url your script basically need to take care of these three things:

    1) Rewrite redirect locations on the server response. (HTTP::header replace Location)

    2) Rewrite response hrefs on server responses html body. (you may use HTTP::stream replace)

    3) Rewrite uri on the client request to translate it to the url that server-side is actually specting


    If you explain the exact use case and url´s you want to convert maybe I can help with concrete tcl code needed.

    Regards

  • MoratoMorato Member

    Thanks,


    My url is  “www.abc.com/ABXBCCOD/opendoc.htm?document=qvw_l%5C.qvw&lang=pt-BR&host=03&anonymous=true”?

    I'd like show at the browser of clients only www.abc.com

    what the best aFlex to do it

    Regards,

  • john_allenjohn_allen Member, A10ers ✭✭

    The A10 GitHub has an example that may work for you: https://github.com/a10networks/aflex-collection/blob/master/url-rewrite-switch.tcl

    -- John

Sign In or Register to comment.