Skip to content

Language Strategy

Last Updated: 2026-03-08

Keep English at root /, Arabic at /ar/. Do not restructure URLs.

Auto-redirect Saudi/GCC visitors to /ar/ using a Cloudflare redirect rule, with a cookie-based preference so users who manually switch languages stay on their chosen language.

  1. First visit from GCC country (no cookie) — Cloudflare 302 redirects to /ar/
  2. User clicks language switcherlang cookie is set (en or ar), 30-day expiry
  3. Return visit with cookie — Cloudflare skips geo-redirect (cookie exists), user stays on preferred language
  4. Visit from non-GCC country — no redirect, sees English
  5. Cookie expires after 30 days — GCC visitors get redirected again
LanguageRootSubpagesExample
English//{page}/services, /prices
Arabic/ar/ar/{page}/ar/services, /ar/prices

English is always the x-default hreflang. No URL restructuring is needed.

File: src/components/Navigation.astro

Both language switcher links (desktop and mobile drawer) have data-lang-switch="en|ar". A <script> at the bottom sets a cookie on click:

document.cookie = `lang=${lang}; path=/; max-age=2592000; SameSite=Lax`;
  • Cookie name: lang
  • Values: en or ar
  • Expiry: 30 days (2592000 seconds)
  • SameSite=Lax for standard browser compatibility
  1. Log in to dash.cloudflare.com
  2. Select urwhats.com domain
  3. Go to Rules > Redirect Rules
  4. Click Create rule
  5. Rule name: GCC Arabic Redirect
  6. Select Custom filter expression, click Edit expression, paste:
    (ip.geoip.country in {"SA" "AE" "KW" "BH" "QA" "OM" "EG" "JO"} and http.request.uri.path eq "/" and not http.cookie contains "lang=")
  7. Then… settings:
    • Type: Dynamic
    • Expression: concat("https://urwhats.com/ar/")
    • Status code: 302
  8. Click Deploy
CodeCountry
SASaudi Arabia
AEUnited Arab Emirates
KWKuwait
BHBahrain
QAQatar
OMOman
EGEgypt
JOJordan

302 is temporary — it tells search engines the root / is still the canonical English page. A 301 would signal a permanent move, which could confuse Google into thinking / should always be Arabic.

  • Zero risk. Hreflang tags already tell Google about both versions.
  • Industry standard. Unifonic, SleekFlow, and other competitors use the same pattern (EN at root, localized at prefix).
  • Google handles it. Google serves the correct language version in search results based on hreflang, regardless of server-side redirects.
  1. npm run build — 0 errors
  2. Open DevTools > Application > Cookies — verify lang cookie is set when clicking language switcher
  3. Deploy Cloudflare rule, test with VPN from Saudi IP:
    • No cookie: homepage redirects to /ar/
    • With lang=en cookie: stays on /
    • With lang=ar cookie: no redirect (cookie exists, Cloudflare skips rule)
  4. Test from non-GCC IP: no redirect regardless of cookie state