Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save WanpengQian/baef29ea0eb172f7f32941905bc1de9b to your computer and use it in GitHub Desktop.
Save WanpengQian/baef29ea0eb172f7f32941905bc1de9b 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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment