Language Strategy
Language Strategy
Section titled “Language Strategy”Last Updated: 2026-03-08
Decision
Section titled “Decision”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.
How It Works
Section titled “How It Works”- First visit from GCC country (no cookie) — Cloudflare 302 redirects to
/ar/ - User clicks language switcher —
langcookie is set (enorar), 30-day expiry - Return visit with cookie — Cloudflare skips geo-redirect (cookie exists), user stays on preferred language
- Visit from non-GCC country — no redirect, sees English
- Cookie expires after 30 days — GCC visitors get redirected again
URL Conventions
Section titled “URL Conventions”| Language | Root | Subpages | Example |
|---|---|---|---|
| English | / | /{page} | /services, /prices |
| Arabic | /ar | /ar/{page} | /ar/services, /ar/prices |
English is always the x-default hreflang. No URL restructuring is needed.
Code Implementation
Section titled “Code Implementation”Language Preference Cookie
Section titled “Language Preference Cookie”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:
enorar - Expiry: 30 days (2592000 seconds)
SameSite=Laxfor standard browser compatibility
Cloudflare Setup (Manual)
Section titled “Cloudflare Setup (Manual)”Redirect Rule
Section titled “Redirect Rule”- Log in to dash.cloudflare.com
- Select urwhats.com domain
- Go to Rules > Redirect Rules
- Click Create rule
- Rule name:
GCC Arabic Redirect - 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=")
- Then… settings:
- Type: Dynamic
- Expression:
concat("https://urwhats.com/ar/") - Status code: 302
- Click Deploy
Countries Included
Section titled “Countries Included”| Code | Country |
|---|---|
| SA | Saudi Arabia |
| AE | United Arab Emirates |
| KW | Kuwait |
| BH | Bahrain |
| QA | Qatar |
| OM | Oman |
| EG | Egypt |
| JO | Jordan |
Why 302 (not 301)
Section titled “Why 302 (not 301)”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.
SEO Impact
Section titled “SEO Impact”- 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.
Testing
Section titled “Testing”npm run build— 0 errors- Open DevTools > Application > Cookies — verify
langcookie is set when clicking language switcher - Deploy Cloudflare rule, test with VPN from Saudi IP:
- No cookie: homepage redirects to
/ar/ - With
lang=encookie: stays on/ - With
lang=arcookie: no redirect (cookie exists, Cloudflare skips rule)
- No cookie: homepage redirects to
- Test from non-GCC IP: no redirect regardless of cookie state