Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let's a consider link such as htttp:// that redirects to htttp://

If I execute 'wget "htttp://"' wget will happily download and save the result in a file named "download.php?id=333". Naming this file "myfile.tar.gz" would have made much more sense.

There is of course the workaround of using 'wget -O myfile.tar.gz "htttp://"' but this is not what I want : I want wget to do the right thing automatically.

Is there any anyway to tell wget to use the name of the target file behind the HTTP redirect ?

I there any other similar tool that would do that ?

share|improve this question
up vote 2 down vote accepted
wget --trust-server-names=on htttp://

Or option trust-server-names in ~/.wgetrc.

It may be a security risk if the HTTP redirect goes to ../../../../../../../../../../../../etc/passwd

share|improve this answer
Now I realize that trusting server names was the former default... And I now understand your reference to CVE-2010-2252 on Twitter ! – Jean-Marc Liotier Sep 24 '10 at 15:50

I found that lynx will often get the file behind the redirect too.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.