Skip to content

Instantly share code, notes, and snippets.

@JustThomas
Created February 4, 2018 17:16
Show Gist options
  • Save JustThomas/74d04d0ae542b6dab9495bce24c0741c to your computer and use it in GitHub Desktop.
Save JustThomas/74d04d0ae542b6dab9495bce24c0741c to your computer and use it in GitHub Desktop.
nginx: Remove double slashes from URLs

Put the following directives in your server block. nginx will then redirect URLs with double (or triple or multiple) slashes to the corresponding URL with a single slash.

merge_slashes off;
rewrite ^(.*?)//+(.*?)$ $1/$2 permanent;
@AhmedElGarhy1
Copy link

the redirect is working fine for pure IP address but when I tried it in a domain it didn't worked
any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment