nginx: rewrite regex to match URL without digit at the end
nginx: rewrite regex to match URL without digit at the end I'm trying to set up a rewrite rule to accomplish the following: /base/first -> /base/search/first /base/first /base/search/first /base/first/second -> /base/search/first/second /base/first/second /base/search/first/second And of course /base/search/first shouldn't redirect to /base/search/search/first /base/search/first /base/search/search/first first and second are placeholders for strings with alphabetical characters and dashes (no digits). first second However, I don't want to rewrite URLs like the following: /base/first/second/third/123 123 is a placeholder for a three-character digits-only string 123 I've tried the following location block and I can get the first two requirements, but it's also capturing URLs that end in 123 123 location ~* ^/base/(?!search)[^d]+$ rewrite ^/base/(?!search)(.+) https://$server_name/base/search/$1 permanent; What is purpose of [^d]+ ? Did you try