Some web servers use the HTTP Referer header to decide whether to serve files, alter responses, or block direct access to download URLs, so sending a custom referer enables scripted downloads that behave more like clicks from a browser page.

The HTTP Referer header carries the URL of the page that initiated a request, and the wget client exposes this value through the --referer option, which injects a chosen URL into the outgoing request while still following redirects, cookies, and other HTTP behavior.

Incorrect or abusive referer spoofing can violate site policies, trigger rate limits, or cause IP bans, so usage must respect terms of service and legal constraints, and any automation should remain conservative and limited to sources that explicitly permit scripted access.

Steps to set a custom referer in Wget:

  1. Open a terminal on a Linux system with wget available.
    $ wget --version
    GNU Wget 1.21.4 built on linux-gnu.
    ##### snipped #####

    Version output confirms that wget is installed and ready to send HTTP requests with custom headers.

  2. Send a download request with a specific referer using the --referer option and a target URL.
    $ wget --referer=https://example.com/download-page/ https://files.example.net/archive.tar.gz
    --2025-12-21 09:08:52--  https://files.example.net/archive.tar.gz
    Resolving files.example.net (files.example.net)... 172.17.0.10
    Connecting to files.example.net (files.example.net)|172.17.0.10|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 362 [application/octet-stream]
    Saving to: 'archive.tar.gz'
    
         0K                                                       100%  307M=0s
    
    2025-12-21 09:08:52 (307 MB/s) - 'archive.tar.gz' saved [362/362]

    The --referer flag sets the outgoing Referer header to https://example.com/download-page/// while the file content is fetched from https://files.example.net// .

  3. Adjust the referer URL so that it matches the real page that normally exposes the download link.
    $ wget --referer="https://example.com/download?from=newsletter&utm_source=mail" \
           https://files.example.net/files/tool.tar.gz

    Wrapping the referer URL in quotes avoids shell parsing issues when query strings or special characters appear in the value.

  4. Combine a custom referer with a browser-like User-Agent string and optional extra headers when a server validates multiple request fields.
    $ wget --referer=https://example.com/download-page/ \
           --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36" \
           --header="Accept-Language: en-US,en;q=0.9" \
           https://files.example.net/archive.tar.gz

    Sending misleading headers to bypass access controls or geographic restrictions may breach site terms of service and can result in account suspension or IP blocking.

  5. Verify that the downloaded file matches the expected size and file type.
    $ ls -lh archive.tar.gz
    -rw-r--r-- 1 alex alex 362 Dec 21 08:19 archive.tar.gz
    
    $ file archive.tar.gz
    archive.tar.gz: gzip compressed data, last modified: Sun Dec 21 07:22:57 2025, from Unix, original size modulo 2^32 4096

    Success signals include an HTTP status like 200 OK in the wget output, a nonzero file size from ls -lh, and a valid file type reported by the file command.

Discuss the article:

Comment anonymously. Login not required.