Redirect old URLs at the edge

Use a dictionary of URL mappings to serve your redirects at lightning speed.

VCL

Use this solution in your VCL service (click RUN below to test this solution or clone it to make changes):

Compute@Edge

Use this solution in your Compute@Edge service:

  1. Rust
let mut solution_redirects = HashMap::new();
solution_redirects.insert("/source1", "/dest1");
solution_redirects.insert("/source2", "/dest2");
if let Some(dest) = solution_redirects.get(req.get_path()) {
let mut new_url = req.get_url().clone();
new_url.set_path(dest);
// Build a redirect response and return it downstream.
Ok(Response::from_status(StatusCode::PERMANENT_REDIRECT).with_header(LOCATION, new_url))
} else {
Ok(req.send(BACKEND_NAME)?)
}