Living Systems_

Creating a static copy of a Drupal, Wordpress or other CMS website

wget -P . -mpck --html-extension -e robots=off --wait 0.5 <URL>

To understand the flags, you can check man wget of course, but some explanations follow here:

After finishing this command, you will have a folder with static HTML-files and other files, that you can just upload to your web server instead of your CMS.

Finally, you might want to add this rule to the Nginx config, to make sure the old non-.html URLs are redirected to the .html variant:

location / {
    if ($request_filename !~* (/|(.+).(html|css|js|gif|png|jpg))$ ) {
        rewrite ^(.+)$ $1.html permanent;
    }
}

Add these lines in the appropriate server config in the relevant file, such as /etc/nginx/sites-enabled/default.

What the rule does, is that for all URLs which are not the home page (/) or static files with any of the common file extensions, it will redirect to the same URL with ‘.html’ padded on at the end.

That’s it! Visit my now archived old blog at saml.rilspace.com for an example if you wish!

Samuel