cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Requesting an Apache virtual host with CURL

From: Dan Fandrich <dan_at_coneharvesters.com>
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 12.34.56.78, but WITHOUT trying to
> resolve 'www.mydomain.com' to an IP first (since it will resolve to
> 12.34.56.78 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 98.76.54.32 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" 98.76.54.32
> curl -H www.domain.com 98.76.54.32
>
> 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.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2006-12-14