I am trying to create redirect to add trailing slash,
location / {
if($request_uri ~ ^([^.]*[^/])$){
return 301 https://$host$request_uri/;
}
}
I have no idea how to do matching in if, when I simply create redirect with / - it works, just this regex seems broken.
UPDATE
Rewrite I tried
location / {
rewrite ^([^.]*[^/])$ $1/ permanent;
.....
}
and
if ($http_x_forwarded_proto != "https") {
return 301 https://$host$request_uri;
}
works fine, redirects to https, I wanted to create regex with it aswell