Wget storing files with question marks

From FVue
Jump to: navigation, search

Problem

I'm trying to download a static mirror of a php website, using wget. Wget however, uses the urls as filenames, e.g.:

index.php?foo=bar

Now when I try to view this file with a webbrowser, the browser has problems interpreting this file as a static HTML file; the browser sees the file above as a php file `index.php' with argument `foo=bar'.

Environment

  • wget-1.12

Solution

wget -r --adjust-extension --convert-links 'http://example.com/index.php?foo=bar'

Option --adjust-extension makes wget save the PHP files with a .html extension.

Option --convert-links makes wget convert the links in the downloaded files to the newly created .html files. Note that this conversion takes place after all files have been downloaded.

See also

lighttpd - How to serve a wget  --mirror'ed directory of files with questionmarks in them - Server Fault
Same problem. User wants to solve the problem by tweaking a local webserver so that it can serve filenames with question marks.