Domain is no longer in use, and I need to make redirects to correct website, but only for specific urls.

server {
    listen 80;

    server_name example.org;

    location ~ ^/(page|show) {
        return 301 http://new-domain.org/$request_uri;

    location = / {
        return 301 http://new-domain.org/;

    return 410;

Only main page and urls matching the pattern will be redirected, everything else should throw 410 HTTP code

but config above is not working, currently everything is throwing 410...


Try putting it in a location. Anything in the server block will always match.

location / {
    return 410;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.