> For the complete documentation index, see [llms.txt](https://docs.proxyman.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.proxyman.com/advanced-features/map-local-directory.md).

# Map Local (Directory)

## 1. What's it?

It's a handy tool to map a matched requests to local files on a selected Directory. If the local files doesn't exist, it will serve from the real server.

If you would like to map a Local File, let check out the Map Local (File) page

{% content-ref url="/pages/-LlQ26G\_ZMrufbuOXtFP" %}
[Map Local (File)](/advanced-features/map-local.md)
{% endcontent-ref %}

## 2. How to use

### 2.1 Map a path and its subdirectories

`api.proxyman.io/build/v1/*` => All sub-paths after `/v1/` will map to a selected directory.

For instance, we select `~/desktop/my_folder` as the local directory

| Real URL                                     | Resolved Local Path              |
| -------------------------------------------- | -------------------------------- |
| <http://api.proxyman.io/build/v1/index.html> | \~/desktop/my\_folder/index.html |
| <http://api.proxyman.io/build/v1/js/main.js> | \~/desktop/my\_folder/js/main.js |

#### How to config

| Rule     | How to use                                                                                      | Examples                                                                                                                      |
| -------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| Wildcard | <ul><li>Check ON "Include subpaths" checkbox</li><li>Or use /\* at the end of the URL</li></ul> | <ul><li>api.proxyman.io/build/v1/ (Check ON)</li><li>api.proxyman.io/build/v1/\*</li></ul>                                    |
| Regex    | <ul><li>Use (.\*) at the end</li></ul>                                                          | <ul><li><https://api.proxyman.io/build/v1/(>.<em>)</em></li><li><em><https://api.proxyman.io/build/v1/(>.</em>.css)</li></ul> |

{% hint style="info" %}
Make sure you use `()` group Regex operator to tell Proxyman where to map
{% endhint %}

### 2.2 Map Entire Host

`api.proxyman.io/*` => All sub-paths will map to a selected directory.

For instance, we select `~/desktop/my_folder` as the local directory

| Real URL                                     | Resolved Local Path                       |
| -------------------------------------------- | ----------------------------------------- |
| <http://api.proxyman.io/build/v1/index.html> | \~/desktop/my\_folder/build/v1/index.html |
| <http://api.proxyman.io/build/v1/js/main.js> | \~/desktop/my\_folder/build/v1/js/main.js |

#### How to config

| Rule     | How to use                                                       | Examples                                                                                                    |
| -------- | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| Wildcard | <ul><li>Leave the path blank</li></ul>                           | <ul><li>api.proxyman.io</li></ul>                                                                           |
| Regex    | <ul><li>Use single path that contains (.\*) at the end</li></ul> | <ul><li><https://api.proxyman.io/(>.<em>)</em></li><li><em><https://api.proxyman.io/(></em>.html)</li></ul> |

## 3. Map Local Directoy with Scripting Tool ✅

If you would like to do Map Local Directory with **complicated rules,** you might check out [Scripting](/scripting/script.md#1-whats-it) since it's easier to achieve the same result.

Please check out our [Snippet Code](/scripting/snippet-code.md#2-common-on-request-and-response) to understand how to map a local file with Javascript Code.
