Skip to content

CloudFront Function and WP Plugin fixes #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adds some help of permanent redirects
  • Loading branch information
nvnivs committed Apr 29, 2022
commit 5ce8093e14809a104e980f6cdf79c9c5889ef029
26 changes: 25 additions & 1 deletion .header.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,34 @@ You may now edit Wordpress as you would normally, customize your site as you lik
section of the WP2Static plugin, and click the 'Generate Static Site' button. This will take some minutes depending on
the size of your site. When complete the site will be published in S3, and available via the public URL configured
in your module definition.

cloudfront_function_301_redirects = {
# Old category pages
"^\\/(pre-historia)$": "/categoria/$1/",
Gentle reminder that no backup options are currently bundled with this module - the most effective means would be to
generate and retain a backup from within Wordpress for maximum flexibility. We recommend the UpdraftPlus plugin.

## Permanent Redirects

Basic url path based permanent redirects are supported via the CloudFront function. The variable `cloudfront_function_301_redirects` can be set with a custom map of match to destination mappings.

Some aspects that need to be taken into consideration for the match:

* It's a regular expression
* Group replacements are supported
* Runs in a Javascript function, escaping needs to be taken into consideration
* Passed through a TF var, so escaping that needs to be taking into account as well

An example to match a path like `/category-name`, a suitable match would be `"^\\/(category-name)$"`. Breaking down the `\\/` part, the first `\` tells TF to escape the second `\`, which is the Regex escape for the `/` character.

An example:

```
cloudfront_function_301_redirects = {
# Redirects /travel to /category/travel/
"^\\/(travel)$": "/category/$1/",
}
```

## Troubleshooting

If you experience issues with the publish element of WP2Static, you can retry. It can be more reliable to proceed to
Expand Down