cURL / Mailing Lists / curl-users / Single Mail


Re: Requesting an Apache virtual host with CURL

From: Dan Fandrich <>
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
> '' from the server, but WITHOUT trying to
> resolve '' to an IP first (since it will resolve to
> 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 '' domain name to the server, but
> WITHOUT trying to resolve the '' 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 ""
> curl -H
> 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:' to set the virtual host.

>>> Dan

--              The web change of address service
          Let webmasters know that your web site has moved
Received on 2006-12-14