title: How to fix wget download file name when the url is redirected
body: <p><code>Wget</code> can't detect filename when 301/302 redirections.  For example, to download the MySQL source code from <a href="http://www.mysql.com/downloads/mirror.php?id=408580" rel="noreferrer">http://www.mysql.com/downloads/mirror.php?id=408580</a></p>
  
  <pre><code>wget http://www.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.25a-linux2.6-x86_64.tar.gz/from/http://cdn.mysql.com/
  </code></pre>
  
  <p>The file will be save as <code>index.html</code></p>
  
  <pre><code>wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.25a-linux2.6-x86_64.tar.gz
  </code></pre>
  
  <p>The file will be save as <code>mysql-5.5.25a-linux2.6-x86_64.tar.gz</code></p>
  
  <p>but the first url is only a redirection for second URL as it is shown in:</p>
  
  <pre><code>curl -I http://www.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.25a-linux2.6-x86_64.tar.gz/from/http://cdn.mysql.com/
  
  HTTP/1.1 302 Found
  Date: Mon, 09 Jul 2012 06:11:50 GMT
  Server: Apache/2.2
  Expires: Thu, 19 Nov 1981 08:52:00 GMT
  Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  Pragma: no-cache
  Set-Cookie: mirror=http%3A%2F%2Fcdn.mysql.com%2F; expires=Sat, 08-Jul-2017 06:11:50 GMT; path=/
  Location: http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.25a-linux2.6-x86_64.tar.gz
  Content-Encoding: gzip
  Vary: Accept-Encoding
  Content-Type: text/html; charset=utf-8
  </code></pre>
  
  <p>How can <code>wget</code> save <a href="http://www.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.25a-linux2.6-x86_64.tar.gz/from/http://cdn.mysql.com/" rel="noreferrer">http://www.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.25a-linux2.6-x86_64.tar.gz/from/http://cdn.mysql.com/</a> as ".tar.gz" automatically (without using <code>-O</code> argument)?</p>