rexhin rexhin - 3 months ago 22
HTTP Question

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

Answer

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

return 301 https://$server_name$request_uri;