LOG IN SIGN UP
Documentation

Conditionally changing a URL

To conditionally change a URL based on the domain, include VCL that looks something like this:

if (req.http.host ~ "^restricted") {
  set req.url = "/sanitized" req.url;
}

If you have shielding enabled, however, add the following code instead to avoid rewriting the URL twice:

if (req.http.host ~ "^restricted" && req.url !~ "^/sanitized") {
  set req.url = "/sanitized" req.url;
}

In Fastly's user interface, this VCL would be the equivalent of creating a new Header in the Content pane of your control panel:

the New Header window set up to restrict a URL

and then creating a request condition that restricts connections to that host:

a New Request Condition set up to restrict a URL


Additional resources: