---
title: Add www. to apex hostname and subdomains
summary: Detect requests that don't include a www. prefix, and redirect to the equivalent path on a hostname that starts with www., usually to make sure there's only one canonical location for your content.
url: https://www.fastly.com/documentation/solutions/examples/add-www.-to-apex-hostname-and-subdomains
---

Detect requests that don't include a www. prefix, and redirect to the equivalent path on a hostname that starts with www., usually to make sure there's only one canonical location for your content.

## VCL

[Try it in Fastly Fiddle](https://fiddle.fastly.dev/28f73aba)

## Compute

### Rust

[Try it in Fastly Fiddle](https://fiddle.fastly.dev/10a6d8d5)

### Javascript

[Try it in Fastly Fiddle](https://fiddle.fastly.dev/2c2ebf89)

### Go

[Try it in Fastly Fiddle](https://fiddle.fastly.dev/1a734936)

