Created
June 28, 2019 00:44
-
-
Save hansspiess/6c9b0bdd5a1faf82550e95ce52568add to your computer and use it in GitHub Desktop.
Create a static copy of a phpwcms site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Redirect Query String to Html file. | |
<IfModule mod_rewrite.c> | |
RewriteCond %{QUERY_STRING} ([a-z0-9]+) [NC] | |
RewriteRule (.*) /%1.html? [R=301,L] | |
</IfModule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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