I\'m trying to redirect requests to https in nginx, unless it is of the form HOST/ANY_STRING_OF_CHARS/END_OF_URI, e.g.:
http://host.org/about # no redirect<
set $test "0";
if ($request_uri ~ "condition") {
set $test "1";
}
if ($test ~ "0") {
return 301 redirect url;
}
Sends a permanent redirect to the client:
server {
listen 80;
rewrite ^(/users/\w+)$ https://$host$1 permanent;
...
}
for negative match you could use:
if ($request_uri !~ "^/users/\w+$")
{
return 301 https://$host$request_uri;
}