Skip to content

Instantly share code, notes, and snippets.

@hansspiess
Created June 28, 2019 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hansspiess/6c9b0bdd5a1faf82550e95ce52568add to your computer and use it in GitHub Desktop.
Save hansspiess/6c9b0bdd5a1faf82550e95ce52568add to your computer and use it in GitHub Desktop.
Create a static copy of a phpwcms site
# Redirect Query String to Html file.
<IfModule mod_rewrite.c>
RewriteCond %{QUERY_STRING} ([a-z0-9]+) [NC]
RewriteRule (.*) /%1.html? [R=301,L]
</IfModule>
# Get all links and stuff. `--adjust-extension` will append a .html extension to the phpwcms query params.
wget -U Mozilla -m -k -D my-domain.com -np "my-domain.com" -e robots=off --adjust-extension
# Replace links in all files. -i writes instantly, the empty '' omits a backup file.
find . -type f -maxdepth 1 -name '*.*' -exec sed -i '' 's/index.php%3F//g' {} +
# Finally rename file names accordingly, cutting off the initial `index.php?` and leaving only the unique query params.
zmv 'index.php?(*)' '${1}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment