req.url
STRING, can be read and set
, but not unset
.
Available inall subroutines.
The full path, including query parameters.
Example
In the request www.example.com/index.html?a=1&b=2
, req.url
will contain
/index.html?a=1&b=2
.
Try it out
req.url
is used in the following code examples. Examples apply VCL to real-world use cases and can be deployed as they are, or adapted for your own service. See the full list of code examples for more inspiration.
Click RUN on a sample below to provision a Fastly service, execute the code on Fastly, and see how the function behaves.
Apply feature flags from an origin API
Park request, make a different request first, use the response to annotate the real origin request (or make decisions about how to route it).
Use microservices to divide up a domain
Send request to different origin servers based on the URL path.
Rewrite URL path
Receive a request for one path but request a different path from origin, without a redirect.
Google Cloud Storage origin (public)
Use a public GCS bucket as a backend for your Fastly service.
Rewrite url based on the subdomain
Check for a subdomain and rewrite the URL path.