当你input“dev1.example.com”。 进入你的浏览器,或者你用HTTP客户端请求该主机,我希望它redirect到“dev1.example.com”。 我试图用下面的服务器块来做到这一点:
server { listen 80; server_name dev1.example.com.; add_header Pragma no-cache; add_header Expires "Sat, 01 Jan 2000 00:00:00 GMT"; add_header Cache-Control "private, no-cache, no-store, max-age=0, must-revalidate, post-check=0, pre-check=0"; return 301 http://dev1.example.com$request_uri; }
但是,似乎没有任何事情发生。 我试图清除我的DNSparsing器caching,清除我自己的浏览器的DNScaching,我甚至用curl请求URL。 我所要求的url是“dev1.example.com”。 我希望它redirect到“dev1.example.com”。
此configuration正在工作。 你可以用CURL检查:
curl -v -H 'Host: dev1.example.com.' -o /dev/null http://dev1.example.com
这是与CURL的交易:
> GET / HTTP/1.1 > User-Agent: curl > Accept: */* > Host: dev1.example.com. > < HTTP/1.1 301 Moved Permanently < Server: nginx < Date: Fri, 25 Jul 2014 04:30:37 GMT < Content-Type: text/html < Content-Length: 184 < Connection: keep-alive < Location: http://dev1.example.com/ < Pragma: no-cache < Expires: Sat, 01 Jan 2000 00:00:00 GMT < Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate, post-check=0, pre-check=0