---
title: req.url.dirname
summary: null
url: >-
  https://www.fastly.com/documentation/reference/vcl/variables/client-request/req-url-dirname
---

**Type:** STRING  
**Access:** read-only

**Available in:** all subroutines

The directories specified in a URL. This will be from the beginning of the URL 
up to the last `/`, not including the query string.

Any trailing slash is stripped. That is, the last `/` will not be part of
`req.url.dirname` unless `req.url.dirname` is `/` (the root directory).

The slash after a directory is required. For example with a URL path of `/xyz/abc?xyz`
the `abc` part is considered a filename (see `req.url.basename`)
and the value of `req.url.dirname` will be `/xyz`.

The directory name is given as `/` when the directory is absent entirely.
For example with a request `www.example.com/hello.html`, `req.url.dirname`
will be `/`.

## Examples

In the request `www.example.com/1/hello.gif?foo=bar`, `req.url.dirname` will 
be `/1`.

In the request `www.example.com/5/inner/hello.gif?foo=bar`, `req.url.dirname` 
will be `/5/inner`.
