IanDess
IanDess

Reputation: 697

nginx case insensitive equals operator

I'm trying to manually redirect a couple of links from my old blog to my new blog like this:

location = /blog-article-url {
    return 301 https://blog.example.com/blog-article-url
}

And this works when i visit https://www.example.com/blog-article-url, i get properly redirected. However it IS case sensitive, if i visit https://www.example.com/BLOG-ARTICLE-URL it will NOT work.

What should i replace the = sign in the nginx config block to make it case insensitive?

Upvotes: 3

Views: 2044

Answers (1)

Richard Smith
Richard Smith

Reputation: 49722

You can do a case insensitive location block with regular expressions.

For example:

location ~* ^/blog-article-url$ { ... }

Note that the evaluation order of regular expression locations is significant - so you may need to move this location block towards the top of your server block. See this document for more.

Upvotes: 3

Related Questions