URL & Routing

Flexible URL structures and automatic language detection for every visitor.

Flexible URL Structures

Choose between subdirectory, subdomain, per-language domain, or a query-parameter (?lang=) layout. Subdomain and per-language domain modes carry the language in the hostname, so they work with any permalink structure; subdirectory mode shines with pretty permalinks (Plain permalinks work too, as long as your server routes every path to WordPress). The query-parameter mode (?lang=de) works with every permalink structure — including Plain — on any server, and always keeps the default language on clean URLs.

Automatic Language Detection

Detect visitor language using a configurable priority chain: URL prefix, cookie, browser language, or GeoIP geolocation. PerfLocale walks the chain in order and stops at the first match — no extra lookups once a language is found.

1
Visitor arrives
IP 198.51.100.42 · no language cookie
2
Country lookup
PerfLocale ships no lookup service — you point it at a source:
  • perflocale/geo/lookup_country Return a country code
  • perflocale/geo/providers Register an HTTP provider
Result cached — 24h by default, no re-query
3
Country → language
🇩🇪 DE → Deutsch
4
302 Redirect
acme-bakery.com/de/

GeoIP Redirect

Redirect first-time visitors to their local language based on the country they're browsing from. PerfLocale bundles no geolocation service and contacts no third party on its own — you decide where the country code comes from. If your CDN already sends one (Cloudflare's CF-IPCountry, for example), returning it from perflocale/geo/lookup_country is a one-liner; otherwise register an HTTP provider through perflocale/geo/providers. PerfLocale handles the country → language mapping, the redirect, and the caching.

PerfLocale Language Fallbacks UI: an ordered, drag-handle list per language. English (US) falls back to English (UK) then Deutsch; English (UK) falls back to English (US); Deutsch falls back to English (US) then English (UK); Français falls back to English (US) then English (UK); Español falls back to English (US); العربية has no fallbacks and uses the Missing Translation Action instead. Click for the full settings row including the row label and description.
Never a redirect chain — just one hop, always

Language Fallbacks

Set an ordered fallback chain per language. When a visitor requests a page that hasn’t been translated yet, PerfLocale walks the list and issues a single redirect to the first published sibling — never a chain of hops. If nothing in the chain matches, the global Missing Translation Action takes over. Read the language-fallback docs.

Self-Healing Rewrite Rules

PerfLocale watches WordPress’s URL routing and rebuilds it the moment something drifts. Pretty URLs never 404 from a stale cache — no manual Save Permalinks trips.

← Back to Features