D
D
Dima_132016-10-07 14:45:36
Nginx
Dima_13, 2016-10-07 14:45:36

How to redirect to a name with the first letter in lower case?

How to make a redirect in nginx from capital to small letter, after the host?
For example: host/Help should be redirected to host/help
host/HelpMe should be redirected to host/helpMe

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Burov, 2016-10-07
@BuriK666

something like this:

map $uri $lowerUri {
    ~^/A(?<part>.*)$ /a$part;
    ~^/B(?<part>.*)$ /b$part;
#  ...
    ~^/Z(?<part>.*)$ /z$part;
}

server {
#  ...
  location / {
    if ($lowerUri != "") {
      rewrite (.*) $lowerUri permanent;
    }        
#  ...
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question