Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

Your Answer


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.