req.url

STRING, can be read and set, but not unset.

Available in all 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 solution recipes, which show real world use cases. Click RUN to provision a Fastly service, execute the code on Fastly, and see how the function behaves.

Preflighting for flags

Park request, make a different request first, use the response to annotate the real origin request (or make decisions about how to route it).

URL path based routing for microservices

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.

User contributed notes

We welcome comments that add use cases, ideas, tips, and caveats. All comments will be moderated before publication. To post support questions, visit our support center and we'll find you the help you need.