Reputation: 91
We' ve currently changed all the structure of our website and moved it from Apache to Nginx. For many links we've set properly 301 redirects, still many pages that don't exist anymore are returning 404 errors. We've a specific list of links that we need to return 410 errors but we don't know how to do that on nginx. Can someone help us on this matter please? Thanks in advance!
Upvotes: 5
Views: 7096
Reputation: 10314
A map might work well here:
http {
# ...
map $uri $gone {
default 0;
~^/old-link1 1;
~^/another-obsolete-link 1;
# consider an included file for these
}
server {
if ($gone) {
return 410;
}
# ...
}
}
Upvotes: 5