Multi domain with one Astro build?

Hello, I created a car manual using Astro and Starlight, but I have a problem with correct settings multidomains.

My app: https://instrukcja-polo6r.netlify.app/

PL: https://polo6r.pl
EN: https://polo6r.net

With Astro I’m building the english version in /dist/en/ directory.

My netlify.toml config file:

[build.environment]
  # bypass npm auto install
  NPM_FLAGS = "--version"
  NODE_VERSION = "20"

[build]
  publish = "dist"
  command = "npx pnpm i --store=node_modules/.pnpm-store && npx pnpm run build"

[[redirects]]
  from = "https://polo6r.pl/*"
  to = "/index.html"
  status = 200

[[redirects]]
  from = "https://polo6r.net/*"
  to = "/en/index.html"
  status = 200


[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200
  conditions = {Language = ["pl"]}

[[redirects]]
  from = "/*"
  to = "/en/index.html"
  status = 200
  conditions = {Language = ["en"]}



[[headers]]
  for = "/manifest.webmanifest"
  [headers.values]
    Content-Type = "application/manifest+json"


[context.production.environment]
LANG = "pl"
SITE_PL_URL = "https://polo6r.pl"
SITE_EN_URL = "https://polo6r.net"

I also added another domain/alias, but when I go to https://polo6r.net I still have the Polish version of the site.
Is what I want to do even possible?
Unfortunately, I could not find any example with a similar configuration.

@spokospace I can’t advise precisely what’s occuring for you, as there seem to be a few things in the mix (cloudflare, astro, redirects, a service worker), but one thing I’ve noticed is…

If I visit the root of:

https://polo6r.net

It’s in Polish.

But if I visit any sub URL at all:

https://polo6r.net/a

It’s in English.

I’m wondering if it’s because all of the rewrites are specified with the wildcard *

You could try specifying some for the root URL (without the wildcard) higher than the wildcard rules.

In your example, I think this configuration works (conditions + language from browser):

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200
  conditions = {Language = ["pl"]}

[[redirects]]
  from = "/*"
  to = "/en/index.html"
  status = 200
  conditions = {Language = ["en"]}

When it comes to domain configurations in netlify I am a novice, about what I currently have:

On Cloudflare I set domain to Netlify’s IP (75.2.60.5)

EN:
A polo6r.net 75.2.60.5

PL:
CNAME polo6r.pl apex-loadbalancer.netlify.com

what I want to achieve is to display the content of /en/ in the domain polo6r.net - currently this only works via Volkswagen Polo V 6R (A05) | Instrukcja obsługi VW Polo 6R

I’m not sure what you’re referring to, I don’t work for Netlify.

I understand this.

Have you tried what I suggested?

Hmm, I have no any other settings to wildcard, only this which is in netlify.toml.

It seems to me, the force = true is needed, so I added it here:

[[redirects]]
  from = "https://polo6r.net/*"
  to = "/en/index.html"
  status = 200
  force = true

But this caused a problem with the correct url to the media (images, javascripts).
Probably also Starlight is not ready for it…

Well, I guess it will be faster to set up a separate version in a second language.

I probably wasn’t clear enough.

I was just suggesting…

If you have:

[[redirects]]
  from = "https://polo6r.pl/*"
  to = "/index.html"
  status = 200

[[redirects]]
  from = "https://polo6r.net/*"
  to = "/en/index.html"
  status = 200

You could try:

[[redirects]]
  from = "https://polo6r.pl"
  to = "/index.html"
  status = 200

[[redirects]]
  from = "https://polo6r.pl/*"
  to = "/index.html"
  status = 200

[[redirects]]
  from = "https://polo6r.net"
  to = "/en/index.html"
  status = 200

[[redirects]]
  from = "https://polo6r.net/*"
  to = "/en/index.html"
  status = 200

Just on the chance that having the /* doesn’t also target /