{"id":187,"date":"2026-11-10T10:54:17","date_gmt":"2026-11-10T10:54:17","guid":{"rendered":"https:\/\/docs.latw.ai\/uncategorized\/languages-on-subdomains-and-domains\/"},"modified":"2026-11-10T10:54:17","modified_gmt":"2026-11-10T10:54:17","slug":"languages-on-subdomains-and-domains","status":"publish","type":"post","link":"https:\/\/docs.latw.ai\/pl\/latw-multilingual\/languages-on-subdomains-and-domains\/","title":{"rendered":"Languages on Subdomains and Separate Domains"},"content":{"rendered":"<p>By default each language lives in a folder of your site: <code>example.com\/pl\/about\/<\/code>. You can instead give<br \/>\nevery language its own <strong>subdomain<\/strong> (<code>pl.example.com\/about\/<\/code>) or its own <strong>domain<\/strong><br \/>\n(<code>example.pl\/about\/<\/code>). The page itself, its translation and its address after the host are the same<br \/>\nin every mode &#8211; only the host changes.<\/p>\n<p><em>Available in the free version (version 2.7.0 and later).<\/em><\/p>\n<h2>Which one to choose<\/h2>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<th>Directory<\/th>\n<th>Subdomain<\/th>\n<th>Separate domain<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Example<\/td>\n<td><code>example.com\/pl\/<\/code><\/td>\n<td><code>pl.example.com<\/code><\/td>\n<td><code>example.pl<\/code><\/td>\n<\/tr>\n<tr>\n<td>DNS and SSL work<\/td>\n<td>none<\/td>\n<td>one record per language (or a wildcard) and a certificate that covers them<\/td>\n<td>a domain per language, each with its own DNS and certificate<\/td>\n<\/tr>\n<tr>\n<td>Login on the language&#8217;s address<\/td>\n<td>yes<\/td>\n<td>only with one <code>wp-config.php<\/code> line (see below)<\/td>\n<td>never<\/td>\n<\/tr>\n<tr>\n<td>Shopping cart carries over between languages<\/td>\n<td>yes<\/td>\n<td>with the <code>COOKIE_DOMAIN<\/code> line; otherwise through the language switcher<\/td>\n<td>yes, through the language switcher<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>If you have no strong reason, stay with <strong>Directory<\/strong>: it needs nothing outside WordPress and has no<br \/>\nlimitations. Choose subdomains or domains when a language needs to look like a site of its own &#8211; a<br \/>\nlocal domain for a local market, for example.<\/p>\n<p>The default language always stays on your site&#8217;s own address (<strong>Settings \u2192 General \u2192 Site Address<\/strong>).<br \/>\nThe admin, the login page and background requests stay on it too, in every mode. Whatever you set<br \/>\nhere changes how visitors see the site, not where you work on it.<\/p>\n<h2>What you must prepare outside WordPress<\/h2>\n<p>WordPress cannot do this part for you, and most problems come from here:<\/p>\n<ol>\n<li><strong>DNS.<\/strong> Every language host must point at the server your site runs on &#8211; one record per<br \/>\nsubdomain, or a wildcard record (<code>*.example.com<\/code>). A separate domain needs its own records.<\/li>\n<li><strong>An SSL certificate that covers every host.<\/strong> A wildcard certificate covers all subdomains; with<br \/>\nseparate domains each one needs a certificate of its own.<\/li>\n<li><strong>The host must reach your WordPress.<\/strong> On most hosting this means adding the subdomain or<br \/>\ndomain as an alias of your site in the hosting panel or the web server&#8217;s configuration. A host that<br \/>\nshows a different site, or a hosting default page, will not work.<\/li>\n<\/ol>\n<h2>Turning it on<\/h2>\n<ol>\n<li>Go to <strong>LATW Multilingual \u2192 Settings \u2192 Languages<\/strong>.<\/li>\n<li>In <strong>Global options<\/strong>, under <strong>Language in URL<\/strong>, pick <strong>Subdomain<\/strong> or <strong>Separate domain per<br \/>\nlanguage<\/strong>.<\/li>\n<li>For subdomains, the hosts are built for you from the URL prefix of each language<br \/>\n(<code>pl<\/code> \u2192 <code>pl.example.com<\/code>; a leading <code>www.<\/code> is dropped). For separate domains, fill in the<br \/>\n<strong>Domain<\/strong> column for every active language &#8211; just the host name, <code>example.pl<\/code>. A pasted<br \/>\n<code>https:\/\/example.pl\/<\/code> is cleaned up.<\/li>\n<li>Click <strong>Check domains<\/strong>. It requests your site through each host and tells you, per host, whether<br \/>\nit works, has no DNS record, has a certificate error, or answers with some other site. You can run<br \/>\nit before saving.<\/li>\n<li>Save. The new addresses work immediately.<\/li>\n<\/ol>\n<p>If <strong>Separate domain per language<\/strong> is selected while an active language has no domain, the rest of<br \/>\nyour settings are saved but the previous mode stays &#8211; so the site keeps working while you finish the<br \/>\nform.<\/p>\n<p><strong>Check domains<\/strong> does not stop you from saving a host that fails. Hosts that are still propagating or<br \/>\nthat only exist on a development machine are legitimate; the check tells you, it does not forbid.<\/p>\n<h2>Changing the mode on a live site<\/h2>\n<p>The old addresses keep working: a visitor, a bookmark or a search result that uses<br \/>\n<code>example.com\/pl\/about\/<\/code> is redirected (permanently, 301) to <code>pl.example.com\/about\/<\/code>, and the other<br \/>\nway round when you go back to <strong>Directory<\/strong> &#8211; as long as the host still points at your site. Search<br \/>\nengines follow these redirects, but expect the usual re-indexing period after any change of address.<br \/>\nIn <strong>Search Console<\/strong>, add every new host as a property, from the same Google account.<\/p>\n<h2>Logging in, the admin bar and editing<\/h2>\n<ul>\n<li><strong>Subdomains.<\/strong> Your login belongs to one host. To be logged in on the language subdomains too (and<br \/>\nsee the admin bar there), add this line to <code>wp-config.php<\/code>, above <em>&#8220;That&#8217;s all, stop editing!&#8221;<\/em>:<br \/>\n<code>define( 'COOKIE_DOMAIN', '.example.com' );<\/code>. The Languages tab shows the exact line for your site.<br \/>\nEveryone is logged out once after the change.<\/li>\n<li><strong>Separate domains.<\/strong> Browsers do not share a login between different domains, so you are never<br \/>\nlogged in on a language&#8217;s domain and there is no admin bar. This is a limit of the web, not of the<br \/>\nplugin.<\/li>\n<li><strong>Page builders<\/strong> (Divi, Beaver Builder, Bricks, Oxygen). The visual editor always opens on your main<br \/>\naddress, because that is where you are logged in. The page shows in the language you are<br \/>\ntranslating anyway.<\/li>\n<li><strong>Previews and &#8220;View&#8221; links.<\/strong> Every preview &#8211; in the page builders and in the standard block<br \/>\neditor &#8211; stays on the main address, where you are logged in, so it shows your unsaved changes. A<br \/>\n&#8220;View&#8221; link opens a translation on its own host and shows it as a visitor sees it &#8211; not logged in.<\/li>\n<\/ul>\n<h2>Shopping cart (WooCommerce)<\/h2>\n<p>A cart is tied to the address it was made on, so with each language on its own host a cart would stay<br \/>\nbehind when a customer switched language. To prevent that, the plugin carries the cart along when the<br \/>\ncustomer <strong>uses the language switcher<\/strong> (or any link to another language&#8217;s host on your own pages):<br \/>\nthe items and any coupons arrive in the other language&#8217;s cart, and the customer lands on the same page<br \/>\nthere. Prices, stock and availability are checked again on arrival, so an item that has meanwhile sold<br \/>\nout is reported instead of added. Pages, the cart&#8217;s AJAX updates and the order confirmation page all stay on the customer&#8217;s<br \/>\nlanguage host.<\/p>\n<p>What it will not do:<\/p>\n<ul>\n<li>It only works through links on your site. A customer who reaches another language by a bookmark or<br \/>\na search result starts with an empty cart there, as no switch happened.<\/li>\n<li>It carries the items and coupons, not the customer: the billing address, email and login stay where<br \/>\nthey were entered.<\/li>\n<li>It does not carry data that other plugins attach to a cart item (a custom text field on a product,<br \/>\nfor example). The product itself arrives; that extra data does not.<\/li>\n<li>The last cart wins: switching to a language replaces the cart that host held before.<\/li>\n<\/ul>\n<p>Nothing is needed from you, and nothing changes in the cached page: links stay as they are, and the<br \/>\ncarrying happens when the customer clicks. With subdomains and the <code>COOKIE_DOMAIN<\/code> line above, the<br \/>\ncart is shared by the browser already and none of this is used.<\/p>\n<p>A payment gateway that calls your shop in the background (a payment notification, a webhook) reaches the<br \/>\nmain address, not a language host, so such a request is handled in your default language. The order<br \/>\nitself keeps the language the customer ordered in.<\/p>\n<h2>Search engines and sitemaps<\/h2>\n<p><code>hreflang<\/code> and canonical tags point at the right host for each language automatically. The sitemap<br \/>\nstays on your main address and lists every language&#8217;s address with its alternates; the <code>robots.txt<\/code><br \/>\nof every language host points crawlers to that one sitemap. Google only<br \/>\naccepts addresses from other hosts when all hosts are verified in Search Console under the same<br \/>\naccount &#8211; do that once for each subdomain or domain.<\/p>\n<h2>Page caching<\/h2>\n<p>A page-caching plugin stores each page under the address it was requested on, so a page on<br \/>\n<code>pl.example.com<\/code> and the same page on <code>example.com<\/code> are cached separately and a visitor never gets<br \/>\nthe wrong language from the cache. Nothing needs to be set up for this. We checked it with WP Super<br \/>\nCache; other caching plugins that keep a separate copy per host behave the same way.<\/p>\n<p>Cached pages hold the language switcher and the <code>hreflang<\/code> and canonical tags, so they have to be<br \/>\nrebuilt when the addresses change. Saving <strong>LATW Multilingual \u2192 Settings \u2192 Languages<\/strong> therefore<br \/>\nempties the page cache of WP Super Cache, WP Rocket, W3 Total Cache, LiteSpeed Cache, SiteGround<br \/>\nOptimizer, Cache Enabler and WP Fastest Cache. With any other caching plugin, or a cache on the<br \/>\nserver or in a CDN (Cloudflare, for example), clear it yourself after changing the mode or adding a<br \/>\nlanguage. Until you do, visitors may still be shown the old addresses.<\/p>\n<p>If you use a CDN or a server cache, make sure it keeps a separate copy per host &#8211; this is the default<br \/>\nfor most, but a rule that ignores the host would serve one language&#8217;s page on another&#8217;s address.<\/p>\n<h2>Visitors&#8217; language choice<\/h2>\n<p>With subdomains, the language a visitor picks is remembered across all of them. With separate<br \/>\ndomains a browser cannot share it, so <strong>Browser auto-detection<\/strong> works on the first visit to your<br \/>\nmain address only; after that, the language host the visitor is on decides.<\/p>\n<h2>What this does not do<\/h2>\n<ul>\n<li>It does not set up DNS, certificates or your hosting &#8211; see <em>What you must prepare outside<br \/>\nWordPress<\/em>.<\/li>\n<li>It does not log you in across different domains.<\/li>\n<li>It does not give the <strong>default<\/strong> language a domain of its own: it stays on your site&#8217;s address.<\/li>\n<li>It is not available on a multisite network.<\/li>\n<li>It does not make a host that points somewhere else work: a visitor on a subdomain you have not<br \/>\nenabled is sent to the main address, but a different name that merely points at the same server<br \/>\n(a hosting alias, a staging domain) is left alone.<\/li>\n<\/ul>\n<h2>Developer reference<\/h2>\n<p>Filters and constants:<\/p>\n<table>\n<thead>\n<tr>\n<th>Name<\/th>\n<th>Purpose<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>latwm_url_mode<\/code> (filter)<\/td>\n<td>Overrides the mode: <code>directory<\/code>, <code>subdomain<\/code> or <code>domain<\/code>. Also the way out if bad DNS takes the language hosts down. The mode is read early, so add the filter in a must-use plugin &#8211; one in a theme&#8217;s <code>functions.php<\/code> is too late.<\/td>\n<\/tr>\n<tr>\n<td><code>LATWM_URL_MODE<\/code> (constant)<\/td>\n<td>Same, from <code>wp-config.php<\/code>.<\/td>\n<\/tr>\n<tr>\n<td><code>latwm_url<\/code> (filter)<\/td>\n<td>The final URL built for a language (unchanged).<\/td>\n<\/tr>\n<tr>\n<td><code>latwm_detected_lang<\/code> (filter)<\/td>\n<td>The language detected for the request (unchanged).<\/td>\n<\/tr>\n<tr>\n<td><code>latwm_legacy_url_redirects<\/code> (filter, default <code>true<\/code>)<\/td>\n<td>Return <code>false<\/code> to switch off the 301s from the previous mode&#8217;s addresses.<\/td>\n<\/tr>\n<tr>\n<td><code>latwm_allow_domain_urls_on_multisite<\/code> (filter, default <code>false<\/code>)<\/td>\n<td>Return <code>true<\/code> to allow the host modes on multisite, at your own risk.<\/td>\n<\/tr>\n<tr>\n<td><code>latwm_cart_handoff<\/code> (filter, default <code>true<\/code>)<\/td>\n<td>Return <code>false<\/code> to switch off carrying the cart to another language host.<\/td>\n<\/tr>\n<tr>\n<td><code>latwm_flush_page_caches<\/code> (action)<\/td>\n<td>Fires after the plugin has emptied the page caches it knows: on saving the Languages tab, and at the end of a request that translated a page into a language for the first time, switched a translation on or off, or changed a translation shown on many pages (menus, strings, forms, categories, header and footer templates). Hook your own cache&#8217;s purge here.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>When the mode is changed by the constant or the filter, the permalink rules are rebuilt automatically<br \/>\non the next request; you do not need to save the permalinks again.<\/p>\n<p><code>latwm_url_strategy()<\/code> returns the object that knows where a language lives in an address:<br \/>\n<code>lang_from_request()<\/code>, <code>lang_from_url( $url )<\/code>, <code>url_for_lang( $url, $lang )<\/code>, <code>lang_home( $lang )<\/code>,<br \/>\n<code>hosts()<\/code>, <code>is_site_host( $host )<\/code>. <code>latwm_get_url( $lang, $url )<\/code> keeps working in every mode.<\/p>\n<p>In the host modes, <code>content_url<\/code>, <code>plugins_url<\/code>, <code>theme_root_uri<\/code>, <code>includes_url<\/code>, <code>rest_url<\/code>,<br \/>\n<code>upload_dir<\/code>, the URLs of enqueued styles and scripts, and the <code>admin-ajax.php<\/code> URL are rewritten to the language host on the front end, so<br \/>\nthat fonts and AJAX requests are not cross-origin. Addresses on any other host (a CDN) are not touched.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default each language lives in a folder of your site: example.com\/pl\/about\/. You can instead give every language its own subdomain (pl.example.com\/about\/) or its own domain\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_latwm_translated_slug":"","footnotes":""},"categories":[4],"tags":[],"class_list":["post-187","post","type-post","status-publish","format-standard","hentry","category-latw-multilingual"],"_links":{"self":[{"href":"https:\/\/docs.latw.ai\/pl\/wp-json\/wp\/v2\/posts\/187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/docs.latw.ai\/pl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.latw.ai\/pl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.latw.ai\/pl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.latw.ai\/pl\/wp-json\/wp\/v2\/comments?post=187"}],"version-history":[{"count":1,"href":"https:\/\/docs.latw.ai\/pl\/wp-json\/wp\/v2\/posts\/187\/revisions"}],"predecessor-version":[{"id":206,"href":"https:\/\/docs.latw.ai\/pl\/wp-json\/wp\/v2\/posts\/187\/revisions\/206"}],"wp:attachment":[{"href":"https:\/\/docs.latw.ai\/pl\/wp-json\/wp\/v2\/media?parent=187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.latw.ai\/pl\/wp-json\/wp\/v2\/categories?post=187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.latw.ai\/pl\/wp-json\/wp\/v2\/tags?post=187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}