Question: When I use wget to obtain a redirect to the URL X URL Y's, wget will automatically get the default URL Y. However, I want to compulsorily acquire URL redirection without X. How do I disable wget redirection URL.
In the HTTP standard, redirect response (HTTP response with the 3XX) Description URL request is moved to a new location. Redirect the corresponding target then contains a URL redirect.
Like regular HTTP client, wget support URL redirection (also called URL forwarding), means that when you try to download a URL redirection, wget will automatically follow URL redirects access to resources are redirected to. If for some reason you want to disable URL redirection, and stop 3XX status code, you can use wget's "--max-redirect = number" option. This option is used to specify the maximum numbers (recursive) redirection, the default is 20.
If you want to disable the HTTP redirect wget, use the "--max-redirect = 0"
$ Wget --max-redirect = 0 http://www.aaa.com/a.html
--2014-10-3123: 08: 58-- http://www.aaa.com/a.html
Resolving aaa.com (aaa.com) ... 126.96.36.199
Connecting to aaa.com (aaa.com) | 188.8.131.52 |: 80 ... connected.
HTTP request sent, awaiting response ... 301MovedPermanently
Location: http://www.bbb.com/b.html [following]
0 redirections exceeded.
As you can see, when wget encounter HTTP redirect response, it does not follow the redirect, and "0 redirections exceeded" (beyond 0 redirects) error message stops. It also displays a HTTP status code (such as 301).
Note curl, another similar HTTP client, the opposite behavior. Default, curl and will not follow URL redirects. To force the cutl redirected to a URL, you have to use "-L" option.