Skip to main content
Docs menu

filter · HTML filters

Add base tag (add_base_tag)

Category:
HTML
CoreFilters:
No
OptimizeForBandwidth:
No
Risk:
Not rated

Adds a <base href="…"> element with the page’s own URL to <head>, so relative URLs in the page resolve against the URL the module rewrote them for. Use it when the HTML is served at a URL other than the one it was authored for (proxy setups, MapProxyDomain). Risk: a page that already relies on a different base, or on the absence of one, resolves its relative links differently; test navigation and form actions.

When to use it

  • Not in CoreFilters: it runs only when you enable it by name.

Risks

The HTML filters page lists no specific risks for this filter. If a page misbehaves with it, DisableFilters add_base_tag 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 add_base_tag

nginx

pagespeed EnableFilters add_base_tag;

IIS (pagespeed.config)

pagespeed EnableFilters add_base_tag

Scoping, ForbidFilters and the thresholds filters read: Choosing filters.

Frequently asked questions

What does the add_base_tag filter do?
Adds a <base href="…"> element with the page's own URL to <head>, so relative URLs in the page resolve against the URL the module rewrote them for. Use it when the HTML is served at a URL other than the one it was authored for (proxy setups, MapProxyDomain). Risk: a page that already relies on a different base, or on the absence of one, resolves its relative links differently; test navigation and form actions.
Is add_base_tag enabled by default?
No. add_base_tag is not in CoreFilters, the default RewriteLevel; it runs only when you enable it by name with EnableFilters.
How do I enable add_base_tag on Apache and nginx?
Add ModPagespeedEnableFilters add_base_tag on Apache or pagespeed EnableFilters add_base_tag; on nginx. On IIS, add pagespeed EnableFilters add_base_tag to pagespeed.config.

This page is drawn from the add_base_tag entry on HTML filters. Every filter in one table: PageSpeed filters.

Search