O
O
Oleg2018-04-04 20:51:21
Nginx
Oleg, 2018-04-04 20:51:21

How to redirect to url in lower case?

Tell me how to correctly redirect from
/Cat/News/100500 to /cat/news/100500/ in nginx (any other ID can be used instead of 100500)
about ~* in the know. Interested in exactly how to do it right
Now I do it all with rewrite like

rewrite ^/Cat/News/([0-9]+) https://site.com/cat/news/$1/ permanent;

Tried wrapping alias in location, getting 404
location = /Cat/News/ {
alias  /cat/news/;
}

In location and alias I tried to use a regular expression as in the example with rewrite, one goblin 404

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg, 2018-04-04
Aldaev

I read that return works faster than rewrite and is more suitable for this task.
While doing so

location ~ ^/Cat/News/([0-9]+)$ {
    return 301 https://site.com/cat/news/$1/;
}

Please advise if there is a better solution.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question