Skip to main content

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_domains

nginx

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 MapRewriteDomain or ShardDomain directives. Useful for CDN integration or domain sharding.
Is rewrite_domains enabled by default?
No. rewrite_domains is not in CoreFilters, the default RewriteLevel; it runs only when you enable it by name with EnableFilters.
How do I enable rewrite_domains on Apache and nginx?
Add ModPagespeedEnableFilters rewrite_domains on Apache or pagespeed EnableFilters rewrite_domains; on nginx. On IIS, add pagespeed EnableFilters rewrite_domains to pagespeed.config.

This page is drawn from the rewrite_domains entry on Cache control. Every filter in one table: PageSpeed filters.

Search