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_tagnginx
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_tagis not in CoreFilters, the default RewriteLevel; it runs only when you enable it by name withEnableFilters. - How do I enable add_base_tag on Apache and nginx?
- Add
ModPagespeedEnableFilters add_base_tagon Apache orpagespeed EnableFilters add_base_tag;on nginx. On IIS, addpagespeed EnableFilters add_base_tagto pagespeed.config.
Related filters
- add_head — Add head
- add_ids — Add IDs
- add_instrumentation — Add instrumentation
- collapse_whitespace — Collapse whitespace
- combine_heads — Combine heads
- compute_statistics — Compute HTML statistics
- convert_meta_tags — Convert meta tags
- debug — Debug comments
This page is drawn from the add_base_tag entry on HTML filters. Every filter in one table: PageSpeed filters.