S
S
Syomka Gavrilenko2020-12-03 17:16:15
Nginx
Syomka Gavrilenko, 2020-12-03 17:16:15

How to properly configure redirect in nginx?

good afternoon!

Tell me how to set up a redirect in nginx from a URL like /question/{question-id}/answer/{answer-id}/ to a URL like
/question/{question-id}/#answer-{answer-id}/
Example:
https://povestka.by/question/15935/answer/15937/ -> https://povestka.by/question/15935#answer-15937

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Hog, 2020-12-03
@cema93

You can use rewrite

location / {
    rewrite ^/question/([0-9]+)/answer/([0-9]+)/$ /question/$1#answer-$2 permanent;
    ...
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question