Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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...

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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