filter · Cache control
Rewrite domains (rewrite_domains)
- Category:
- Caching
- CoreFilters:
- No
- OptimizeForBandwidth:
- No
- Risk:
- Test first
Rewrites resource URLs to use domains specified by MapRewriteDomain or ShardDomain directives. Useful for CDN integration or domain sharding.
How it works
This filter only affects resources that mod_pagespeed does not otherwise optimize. Resources already rewritten by other filters (rewrite_css, rewrite_images, etc.) already have their domains set by those filters.
See Domain configuration for MapRewriteDomain and ShardDomain setup.
When to use it
- Not in CoreFilters: it runs only when you enable it by name.
- Risk rating on these docs: Test first.
Risks
The
Cache control
page lists no specific risks for this filter.
If a page misbehaves with it, DisableFilters rewrite_domains turns it off for
the scope you set it in.
Configuration
Enable it in the module configuration, at server, virtual-host or location scope:
Apache
ModPagespeedEnableFilters rewrite_domainsnginx
pagespeed EnableFilters rewrite_domains;IIS (pagespeed.config)
pagespeed EnableFilters rewrite_domains
Scoping, ForbidFilters and the thresholds filters read:
Choosing filters
.
Frequently asked questions
- What does the rewrite_domains filter do?
- Rewrites resource URLs to use domains specified by
MapRewriteDomainorShardDomaindirectives. Useful for CDN integration or domain sharding. - Is rewrite_domains enabled by default?
- No.
rewrite_domainsis not in CoreFilters, the default RewriteLevel; it runs only when you enable it by name withEnableFilters. - How do I enable rewrite_domains on Apache and nginx?
- Add
ModPagespeedEnableFilters rewrite_domainson Apache orpagespeed EnableFilters rewrite_domains;on nginx. On IIS, addpagespeed EnableFilters rewrite_domainsto pagespeed.config.
Related filters
- extend_cache_pdfs — Extend cache for PDFs
- local_storage_cache — Local storage cache
- extend_cache — Extend cache
This page is drawn from the rewrite_domains entry on Cache control. Every filter in one table: PageSpeed filters.