Z
Z
zednight2017-03-29 09:10:34
Nginx
zednight, 2017-03-29 09:10:34

Nginx how to make a redirect condition based on response status and url pattern?

SEO specialists set the task: If the url does not contain a slash at the end, then perform a redirect only if the response is 200, otherwise immediately issue a 404. It turns out that you need to either solve the issue at the php application level, or intercept nginx response status and perform a redirect only if there is no slash at the end and the response code is 200. How can it be implemented at the nginx level?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
floydback, 2017-03-29
@floydback

Just think: if the server response is successful 200 (document found), then do a 302 redirect, and if, for example, the response is 202 (which is also a successful response), then respond with a 404 error. It smacks of nonsense, agree.
Either you misunderstood the task, or the SEOs suggest doing something stupid.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question