Docs

This page isn't translated yet

Public URL recipes

Hosting patterns for prefixed paths, subdomains and separate domains.

On this page

routing.domains maps every supported locale to its canonical public origin. Each locale then owns an unprefixed path on its origin; the internal locale segment still reaches the same generated Next route tree. Domain routing does not require per-domain folders, copied layouts, or another dependency. For prefix routing, see Frontend locales.

Separate production domainsLink to this section

Separate production domains:

locales: defineSysthemaLocales({
  supported: ['en', 'hu'],
  default: 'en',
  routing: {
    domains: { en: 'example.com', hu: 'pelda.hu' },
  },
})
// https://example.com/slug, https://pelda.hu/slug

Locale subdomainsLink to this section

Locale subdomains:

locales: defineSysthemaLocales({
  supported: ['en', 'hu'],
  default: 'en',
  routing: {
    domains: { en: 'en.example.com', hu: 'hu.example.com' },
  },
})
// https://en.example.com/slug, https://hu.example.com/slug

Mixed domains and shared subfoldersLink to this section

Mixed dedicated domains and shared subfolders — point several locales at one host to group them:

locales: defineSysthemaLocales({
  supported: ['en', 'hu', 'fr', 'nl', 'de'],
  default: 'en',
  routing: {
    domains: {
      en: 'example.com', // dedicated → served unprefixed
      hu: 'example.hu', // dedicated → served unprefixed
      fr: 'example.eu', // shared host → served at /fr
      nl: 'example.eu', // shared host → served at /nl
      de: 'example.eu', // shared host → served at /de
    },
  },
})
// example.com/slug, example.hu/slug, example.eu/fr/slug, example.eu/nl/slug, example.eu/de/slug

A host with one locale serves it unprefixed; a host shared by two or more locales path-prefixes each so they keep distinct URLs. Every downstream surface (canonical/alternate URLs, sitemaps, revalidation, Preview) follows this automatically. A shared host cannot serve one of its locales unprefixed — give that locale its own dedicated host instead.

Custom subfoldersLink to this section

Each prefix-routed locale can also override its public URL segment via the advanced form's subfolder (defaults to the locale code) — e.g. ar: { rtl: true, subfolder: 'arabic' } serves that locale at /arabic/slug instead of /ar/slug, in both pure prefix mode and on a locale sharing a host in domain mode; it throws on a dedicated-domain locale, which always serves unprefixed. Internal routing — the generated catch-all's segments, revalidation cache keys, static params — always stays on the locale code; subfolder only changes what the browser sees, and next-intl's middleware rewrites the public /arabic/slug request to the internal /ar/slug route. See Advanced per-locale form for the full validation rules.

Local production buildsLink to this section

Local production-build testing uses the same contract and one Next server:

locales: defineSysthemaLocales({
  supported: ['en', 'hu'],
  default: 'en',
  routing: {
    domains: {
      en: 'http://en.localhost:3000',
      hu: 'http://hu.localhost:3000',
    },
  },
})
// http://en.localhost:3000/slug, http://hu.localhost:3000/slug

Validation and redirectsLink to this section

Host-only production values normalize to HTTPS. Explicit HTTP origins are for loopback development. A domain map must include every supported locale and use one protocol, and contain origins only — no path, credentials, query, or fragment. Hosts may be shared (grouping their locales under path prefixes) or dedicated. A request that lands on the wrong host for its locale redirects to the canonical URL — https://en.example.com/hu/slug → the unprefixed https://hu.example.com/slug on a dedicated host, or the prefixed path on a shared host — preserving its query string. The same rule applies when Preview explicitly selects another locale.

Public path and href helpers describe browser-facing URLs; they are not cache invalidation keys. Next's generated catch-all route and Payload revalidation use the dedicated internal locale path (/<locale><pathname>) for every enabled locale mode, including an unprefixed default locale and domain routing. This prevents two public hosts that both expose /slug from sharing one on-demand revalidation target.

Sitemaps on several hostsLink to this section

For production domain routing, treat every locale host as a sitemap deployment surface. Make each host discover its sitemap from that host's robots.txt, or publish a sitemap index that references the per-host sitemap files if the search tool supports cross-site submission. Verify ownership of every domain or subdomain in the relevant search tooling and submit/discover each host; do not assume submitting only the default locale host covers URLs on the others.