To pass a custom Host
header with the curl
command in Linux or Unix, you can use the -H
option followed by the Host:
header and the hostname.
For example, to pass the Host
header www.example.com
with a curl
request to http://localhost
, you can use the following command:
curl -H 'Host: www.example.com' http://localhost
This will send an HTTP request to http://localhost
with the Host: www.example.com
header, indicating that the request is intended for the host www.example.com
.
You can also use the --header
option to set the Host
header manually:
curl --header 'Host: www.example.com' http://localhost
This will have the same effect as using the -H
option.
Keep in mind that the Host
header is required in HTTP/1.1 requests and is used to specify the hostname of the server that the request is intended for. Some servers may block or ignore requests that do not include a Host
header, or may treat them differently based on the value of the header.