Reference URL: https://developers.cloudflare.com/rules/url-forwarding/
Review the Cloudflare Dynamic Redirect Rule below for issues:
- Rule Name:
Enforce Trailing Slash in URL Paths via 301 Redirect
(
(
http.host eq "www.example.com" or
http.host eq "dev.example.com" or
http.host eq "qa.example.com"
) and
not http.request.uri.path matches "\.(7z|apk|avi|avif|bin|bmp|bz2|class|css|csv|dmg|doc|docx|ejs|eot|eps|exe|flac|html?|gif|gz|ico|iso|jar|jpeg|jpg|js|json|mid|midi|mkv|mp3|mp4|ogg|otf|pdf|pict|pls|png|ppt|pptx|ps|rar|svg|svgz|swf|tar|tif|tiff|ttf|webm|webp|woff|woff2|xls|xlsx|zip|zst)$" and
not http.request.uri.path contains "/api/" and
not http.request.uri.path contains "/_next" and
(
not ends_with(http.request.uri.path, "/") and
not http.request.uri.path matches "\.[a-zA-Z0-9]{2,4}$"
)
)
- Type:
Dynamic
- Expression:
lower(concat(http.request.uri.path,"/"))
- Status Code:
301
- Preserve query String?:
true