How can I get visitors redirected to a specific html page if the name used to resolve the server address was a specific one? I tried

if ($http_host ~ /forbiddenname/)
    rewrite ^(.*)$ /updateyourlinks.html break;

inside the Server section, but doesn't work...


After some research I found that I should use instead of an if a virtual host... what I've added to nginx configuration is another server

server {
    listen 80;
    server_name *.badname.com;
    rewrite ^ http://goodname.com/updateyourlinks.html;

and this apparently works

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.