要将类似 /images/<FOLDER1>/<FOLDER2>/<FILENAME> 的路径(其中 <FOLDER1>、<FOLDER2> 和 <FILENAME> 可变)重写为 /img/<FILENAME>,请创建一条对路径组件进行动态重写的 URL 重写规则:
Expression Editor(表达式编辑器) 中的文本:
http.request.uri.path ~ "^/images/[^/]+/[^/]+/[^/]+$"Path(路径) > Rewrite to(重写为) > Dynamic 之后的文本:
regex_replace(http.request.uri.path, "^/images/[^/]+/[^/]+/(.+)$", "/img/${1}")例如,此规则会将 /images/nature/animals/tiger.png 路径重写为 /img/tiger.png。