www resolution
The site works whether users type www or not.
Link copied!
On this page
Impact
About
Domain canonicalization allows access to the intended website address, whether users type www (www.example.gov) or not (example.gov). Improper canonicalization will fail to direct example.gov to the intended address, and users will receive an error.
Risks
Users get errors when typing your web address.
Why it's important
Ensures consistent site display whether users type with or without 'www,' preventing errors and improving overall accessibility.
User stories
As a site visitor, I want to access the website using either www or non-www URLs and be automatically redirected to the correct version so that I don't encounter errors or duplicate content.
Code
nginx — redirect non-www to www (or www to non-www, pick one canonical form):
# Redirect www to non-www
server {
listen 80;
server_name www.example.gov;
return 301 https://example.gov$request_uri;
}
server {
listen 443 ssl;
server_name www.example.gov;
return 301 https://example.gov$request_uri;
}
Error
ScanGov messaging when a site fails a standard:
www and non-www versions are inconsistent.
Examples
Example of a government website with www and non-www resolution:
Guidance
Indicators
Related
- Page title
- Page description
- Readability
- Viewport meta tag
- Cumulative Layout Shift (CLS)
- First Contentful Paint (FCP)
- Interaction to Next Paint (INP)
- Largest Contentful Paint (LCP)
- Time to First Byte (TTFB)
- Open Graph site name
- Open Graph type
- Open Graph title
- Open Graph description
- Open Graph URL
- Open Graph image
- Open Graph image alt
- Usability grades on Project ScanGov
- ScanGov Usability
On this page