Ngnix как сделать редирект с двойных слешов в URLe (mysite.com//*)

2017-09-03 | 20:34
Tags: • python djangoseo
    # Tested against:
    #   http://www.example.com//
    #   http://www.example.com/w//w//w//
    #   http://www.example.com//?//

 server {
        listen 80;
        server_name 178.62.205.152
        access_log  /var/log/nginx/example.log;
        
# Remove any multislashes in the url
    if ($request_uri ~* "\/\/") {
      rewrite ^/(.*)      $scheme://$host/$1    permanent;
    }


        location /static/ {
            root /home/v_www/www/;
            expires 30d;
        }

        location / {
            proxy_pass http://127.0.0.1:8000; 
            proxy_set_header Host $server_name;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

      }