Answer the question
In order to leave comments, you need to log in
How to make a 301 redirect, like on Habré?
I'm going to launch one Wordpress project with a link structure: http://site.ru/category/12345/
And I need to make sure that if something else is added to this address "by mistake", then 301 instead of 404 would work on the same page. Such implementation is used on Habré. example:
http://habrahabr.ru/post/212003/
http://habrahabr.ru/post/212003/ошибочний текст/
How to do it, who knows?
Answer the question
In order to leave comments, you need to log in
And habr does not redirect anywhere.
They simply rewrite in nginx in such a way that it does not take into account the third section of the uri (and beyond).
But if you need a rewrite, then something like this:
location something like this {
...
error 404 = @errorloc
...
}
location @errorloc {
rewrite ^/(.*)/(.*)/.* $scheme:// $http_host/$1/$2 permanent;
}
Approximately so.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question