Cloudflare rule: strip trailing slash

I’m able to remove trailing slashes by having two redirect rules:

  • No query string:*/ ->$1
  • Yes query string:*/?* ->$1?$2

But I’d prefer to do this with one rule.

I tried:

  • No/Yes query string:*/\??* ->$1$2

But I can’t seem to get it working.
Any ideas on something else to try?

If you’re running Apache, you might be able to do it with .htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect to non-trailing slash
RewriteRule ^(.*)/$ /$1 [R=301,L]
1 Like