Re: Requesting an Apache virtual host with CURL
Date: Wed, 13 Dec 2006 20:54:26 -0800
On Wed, Dec 13, 2006 at 08:35:15PM -0800, John Sherling wrote:
> So my question is: can I to tell CURL to request the site
> 'www.mydomain.com' from the server 188.8.131.52, but WITHOUT trying to
> resolve 'www.mydomain.com' to an IP first (since it will resolve to
> 184.108.40.206 and show me the old live site)?
> Again, for various reaasons, I DONT want to use any kind of DNS tricks
> to solve the problem. I want to know if CURL can make a request for
> the 'www.mydomain.com' domain name to the 220.127.116.11 server, but
> WITHOUT trying to resolve the 'www.mydomain.com' hostname first.
> I thought there may be a way to use headers to do it (since that's how
> browsers handle virtual hosts on webservers), so I tried:
> curl -H "http://www.domain.com" 18.104.22.168
> curl -H www.domain.com 22.214.171.124
> but when I try this, curl always does a lookup on the hostname, and
> sends me to the old server.
There are a couple of ways you can do this. You can add an entry in
/etc/hosts (or equivalent) with the new address and curl will use that
to connect to the host. Or, you can use the -H trick you were so close to
getting working. -H takes a whole HTTP header, so you need to do
-H 'Host: www.domain.com' to set the virtual host.
-- http://www.MoveAnnouncer.com The web change of address service Let webmasters know that your web site has movedReceived on 2006-12-14