Introduction

Modify URI of HTTP request based on defined rules.

Configuration

  • Module config file

    conf/mod_rewrite/mod_rewrite.conf

    1. [basic]
    2. DataPath = ../conf/mod_rewrite/rewrite.data
  • Rule config file

    conf/mod_rewrite/rewrite.data

    | Config Item | Type | Description || —————- | ——— | —————————————————————————————— || Version | String | Verson of config file || Config | Struct | Rewrite rules for each product. Rewrite rule include: - Cond: “condition” expression - Actions: what to do after matched- Last: if true, stop to check the remaining rules |

    | Action | Description || ————————————- | ———————————————————— || HOST_SET | Set host to specified value || HOST_SET_FROM_PATH_PREFIX | Set host to specified path prefix || PATH_SET | Set path to specified value || PATH_PREFIX_ADD | Add prefix to orignal path || PATH_PREFIX_TRIM | Trim prefix from orignal path || QUERY_ADD | Add query || QUERY_DEL | Delete query || QUERY_DEL_ALL_EXCEPT | Del all queries except specified queries || QUERY_RENAME | Rename query |

    1. {
    2. "Version": "20190101000000",
    3. "Config": {
    4. "example_product": [
    5. {
    6. "Cond": "req_path_prefix_in(\"/rewrite\", false)",
    7. "Actions": [
    8. {
    9. "Cmd": "PATH_PREFIX_ADD",
    10. "Params": [
    11. "/bfe/"
    12. ]
    13. }
    14. ],
    15. "Last": true
    16. }
    17. ]
    18. }
    19. }