I am trying to mirror a complete website to another domain.

I am trying to use

wget -mk http://example.com

However the -k option leaves some URLs original while other are converted such as:

<link rel="stylesheet" href="http://example.com/templates/css/style.css" type="text/css" />
<!--[if lt IE 8]>
  <link rel="stylesheet" href="/templates/css/ie.css" type="text/css" />
<!--[if lt IE 7]>
  <link rel="stylesheet" href="/templates/css/ie6.css" type="text/css" />

Or img tags:

<img src="http://example.com/templates/img/logo.jpg"

While a-tags are converted properly.

These are from index.html, and the output of wget states, that index.html got converted

Converting example.com/index.html... 30-12

Why does this happen?


This from the wget manpage, which probably explains what you're seeing:

-k --convert-links

After the download is complete, convert the links in the document to make them suitable for local viewing. This affects not only the visible hyperlinks, but any part of the document that links to external content, such as embedded images, links to style sheets, hyperlinks to non-HTML content, etc.

Each link will be changed in one of the two ways:

  • The links to files that have been downloaded by Wget will be changed to refer to the file they point to as a relative link.

Example: if the downloaded file /foo/doc.html links to /bar/img.gif, also downloaded, then the link in doc.html will be modified to point to ../bar/img.gif. This kind of transformation works reliably for arbitrary combinations of directories.

  • The links to files that have not been downloaded by Wget will be changed to include host name and absolute path of the location they point to.

Example: if the downloaded file /foo/doc.html links to /bar/img.gif (or to ../bar/img.gif), then the link in doc.html will be modified to point to http://hostname/bar/img.gif.

Without further details it's difficult to be more precise.

  • 1
    i also tried to use --page-requisites which should download all links but doesnt. commandline I used now wget --mirror --convert-links --adjust-extension --page-requisites --no-parent example.com but still css, and imgs are not downloaded Feb 6 '15 at 15:39
  • @Jherek are your missing css files, etc., really on the same website? (Remembering, of course, that example.net is not the same as www.example.net.)
    – roaima
    Feb 6 '15 at 16:34
  • 1
    The man page has been updated to emphasise this: Note that only at the end of the download can Wget know which links have been downloaded. Because of that, the work done by -k will be performed at the end of all the downloads., which solved the problem for me.
    – Jia Ming
    Jun 23 at 19:52

It may be that there is a robots.txt file on the server. The option -e robots=off would help in that case. (It did for me in a similar situation.)


In case the mirrored site is protected by HTTP Auth, one needs to use command line options to provide username and password. Something like --http-user=someone and --http-password=secret seems to work. Specifying the credentials as part of the url, https://someone:secret@somewhere/, gives the unexpected situation where only some files get downloaded, while wget attempts to fetch other files without authenticating. I'm sure there is a pattern and a sound reason for it, but I did not bother investigating the differences between the accessible and inaccessible links.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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