Some servers check the Referer header to control access. By specifying a custom referer, you can simulate coming from a particular page, enabling downloads that would otherwise be blocked or altered based on the perceived origin.
wget allows adjusting the referer easily. This feature helps bypass basic restrictions or replicate browser navigation patterns, enabling automation of protected downloads. However, always respect the website’s policies and ethical guidelines.
Custom referers are useful for scraping resources that only load when the request appears to originate from a specific page, ensuring reproducible and predictable data retrieval.
Steps to set a custom referer in Wget:
- Open the terminal on your system.
- Use the --referer option followed by the URL you want to send as the referer.
$ wget --referer=http://example.com/referer-page/ http://targetwebsite.com/download/file.zip --2024-09-16 13:45:05-- http://targetwebsite.com/download/file.zip Resolving targetwebsite.com (targetwebsite.com)... 93.184.216.34 Connecting to targetwebsite.com (targetwebsite.com)|93.184.216.34|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 19834 (19K) [application/zip] Saving to: ‘file.zip’ file.zip 100%[===================>] 19.36K --.-KB/s in 0s 2024-09-16 13:45:06 (421 MB/s) - ‘file.zip’ saved [19834/19834]
This command sets the referer to http://example.com/referer-page// and downloads the file from http://targetwebsite.com//.
- Verify the downloaded content for accuracy and completeness.
- Combine the --referer option with other Wget options if needed, such as setting a user agent or additional headers.
$ wget --referer=http://example.com/referer-page/ --user-agent="Custom User Agent" --header="Custom-Header: Value" http://targetwebsite.com/download/file.zip
This command combines the custom referer with a custom user agent and additional header.
- Use this command within scripts or automation tasks for repetitive actions.
- Ensure compliance with website policies when using these options.

Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
Comment anonymously. Login not required.