How to implement Nginx case-insensitive directory-location redirection 301

nginx

Solution

I'm assuming that http://example.com/something would not be redirected. So use a prefix location for the case sensitive match with the `^~` modifier to skip checking regular expressions:

location ^~ /something {
    return 200 "case sensitive something match
";
}

Now add the case insensitive regular expression location for the redirect:

location ~* ^/something {
    return 301 $scheme://$host/something;
}

Problem

I want to http://example.com/SomeThing redirect to http://example.com/something `something` is nginx location (`/something`) directory Please suggest how to implement case insensitive directory location redirection

Original source