开发者

How to redirect any request to a specific page if the visitor was using a certain name?

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 ^(.*)$ /updateyourlink开发者_运维知识库s.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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜