M1X
M1X

Reputation: 5354

nginx remove extra trailing slash ate the end of URL

I have this configuration inside server block which redirects all http requests to the https server with a 301, moved permanently status.

The problem is that in Screaming Frog or Chrome I can see that http://kida.al is redirected to https://kida.al// and then to https://kida.al/.

How can I prevent such a thing?

Thanks!

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    server_name kida.al;

    return      301 https://$server_name$request_uri/;
}

enter image description here

Upvotes: 0

Views: 502

Answers (1)

VBart
VBart

Reputation: 15110

You should remove the extra trailing slash from the end of your redirection path:

return 301 https://$server_name$request_uri;

Upvotes: 1

Related Questions