cloudflaretrailing-slash

Cloudflare page rules for removing multiple trailing slash


I want to set up the below things in Cloudflare.

https://example.com// OR https://example.com// OR https://example.com/// OR onwards

are redirecting to https://example.com/

How can I set up this using the Cloudflare page rule?


Solution

  • It will be quicker to set that in your webserver(Nginx) virtual host than doing it on Cloudflare.

    Add below in your Nginx config:

    if ($request_uri ~* "\/\/") {
      rewrite ^/(.*)      https://$host/$1    permanent;
    }