# How to hide directory from URL site

**URL:** <https://community.a10networks.com/t/how-to-hide-directory-from-url-site/577>\
**Category:** aFleX\
**Created:** [November 28, 2019, 7:11pm UTC](https://community.a10networks.com/t/how-to-hide-directory-from-url-site/577 "2019-11-28T19:11:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Morato](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@Morato](https://community.a10networks.com/u/Morato)\
**Post date:** [November 28, 2019, 7:11pm UTC](https://community.a10networks.com/t/how-to-hide-directory-from-url-site/577/1 "2019-11-28T19:11:04Z")

</div>

Hi!!  
I’d like how I can hide the directory from the site as example bellow:  
Site: [http://site.com/index.php?page=items](http://site.com/index.php?page=items)  
But in the browser only show [http://site.com/](http://site.com/)  
Is that possible be configurated in A10?  
Thanks,  
Rafael Morato

---

<div class="post-metadata">

**Author:** ![jserrano](https://avatars.discourse-cdn.com/v4/letter/j/a9a28c/32.png) [@jserrano](https://community.a10networks.com/u/jserrano)\
**Post date:** [November 28, 2019, 9:20pm UTC](https://community.a10networks.com/t/how-to-hide-directory-from-url-site/577/2 "2019-11-28T21:20:32Z")

</div>

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/”} {  
&nbsp;HTTP::uri "[string map { “/external/url/“ “/internal/url/” } [HTTP::uri]]”  
}  
}  
when HTTP\_RESPONSE {  
if { [HTTP::is\_redirect] } {  
&nbsp;HTTP::header replace Location “[string map { “/internal/url/” “/external/url/” } [HTTP::header Location]]”  
}  
&nbsp;HTTP::stream replace “/internal/url/” "/external/url/“

}

Hope this help!  
José Serrano

---

<div class="post-metadata">

**Author:** ![Morato](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@Morato](https://community.a10networks.com/u/Morato)\
**Post date:** [November 29, 2019, 12:56pm UTC](https://community.a10networks.com/t/how-to-hide-directory-from-url-site/577/3 "2019-11-29T12:56:25Z")

</div>

Thank you José Serrano,  
I’m going to try that and report here if that works or not.

Regards,  
Rafael Morato

---

<div class="post-metadata">

**Author:** ![Morato](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@Morato](https://community.a10networks.com/u/Morato)\
**Post date:** [December 4, 2019, 9:26pm UTC](https://community.a10networks.com/t/how-to-hide-directory-from-url-site/577/4 "2019-12-04T21:26:10Z")

</div>

I’ve tried that script, but that didn’t works.  
I tried to run that:  
when HTTP\_RESPONSE {  
&nbsp; 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

---

<div class="post-metadata">

**Author:** ![jserrano](https://avatars.discourse-cdn.com/v4/letter/j/a9a28c/32.png) [@jserrano](https://community.a10networks.com/u/jserrano)\
**Post date:** [December 11, 2019, 12:32pm UTC](https://community.a10networks.com/t/how-to-hide-directory-from-url-site/577/5 "2019-12-11T12:32:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Morato](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@Morato](https://community.a10networks.com/u/Morato)\
**Post date:** [December 16, 2019, 7:32pm UTC](https://community.a10networks.com/t/how-to-hide-directory-from-url-site/577/6 "2019-12-16T19:32:14Z")

</div>

Thanks,

My url is &nbsp;“[www.abc.com/ABXBCCOD/opendoc.htm?document=qvw\_l%5C.qvw&lang=pt-BR&host=03&anonymous=true](http://www.abc.com/QvAJAXZfc/opendoc.htm?document=qvw_l%5Cpainelcnj.qvw&lang=pt-BR&host=QVS%40neodimio03&anonymous=true)”?  
I’d like show at the browser of clients only [www.abc.com](http://www.abc.com/QvAJAXZfc/opendoc.htm?document=qvw_l%5Cpainelcnj.qvw&lang=pt-BR&host=QVS%40neodimio03&anonymous=true)  
what the best aFlex to do it  
Regards,

---

<div class="post-metadata">

**Author:** ![john\_allen](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@john\_allen](https://community.a10networks.com/u/john_allen)\
**Post date:** [December 28, 2019, 1:07am UTC](https://community.a10networks.com/t/how-to-hide-directory-from-url-site/577/7 "2019-12-28T01:07:38Z")

</div>

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