Setting Up a Multi-Regional Website (Different Content by Region)
Multi-regional website — one domain with different content based on user region. Moscow user sees Moscow prices, Krasnodar user sees their promotions and local contacts, Kazakhstan user sees tenge prices. Task is more complex than it seems: align region detection, content storage, routing, SEO and caching.
Architectural Options
Option 1: Subdirectories — site.ru/msk/, site.ru/spb/, site.ru/krd/
Simplest for SEO, clear for users, easy on any framework. Google indexes each region separately.
Option 2: Subdomains — msk.site.ru, spb.site.ru
Requires wildcard certificate and *.site.ru DNS. Easier to split cache by region on CDN. Technically cleaner but Google may see subdomains as separate sites — worse domain authority.
Option 3: Auto-detection without URL change
User always on site.ru, region detected by IP. Bad for SEO — Googlebot doesn't crawl different regions, always sees one. Only suitable if regional content doesn't need indexing.
Option 1 is optimal for most projects.
Data Model
CREATE TABLE regions (
id SERIAL PRIMARY KEY,
slug VARCHAR(16) UNIQUE NOT NULL, -- 'msk', 'spb', 'krd'
name VARCHAR(128) NOT NULL,
is_default BOOLEAN DEFAULT false,
currency VARCHAR(3) DEFAULT 'RUB',
phone VARCHAR(32),
address TEXT
);
-- Regional content overrides
CREATE TABLE content_region_overrides (
content_id INTEGER NOT NULL,
region_id INTEGER NOT NULL REFERENCES regions(id),
field VARCHAR(64) NOT NULL, -- 'price', 'title', 'body'
value TEXT,
PRIMARY KEY (content_id, region_id, field)
);
Base content stored in main table. Regional overrides — only what differs. Saves space and simplifies sync: changing base content automatically updates regions without overrides.
Routing (Laravel)
// routes/web.php
Route::prefix('{region}')
->where(['region' => '[a-z]{2,8}'])
->middleware('region.resolve')
->group(function () {
Route::get('/', [HomeController::class, 'index']);
Route::get('/catalog/{slug}', [CatalogController::class, 'show']);
Route::get('/contacts', [ContactsController::class, 'index']);
});
// Root without region — redirect to detected region
Route::get('/', RegionDetectController::class);
// app/Http/Middleware/ResolveRegion.php
public function handle(Request $request, Closure $next): Response
{
$slug = $request->route('region');
$region = Region::where('slug', $slug)->firstOrFail();
// Available throughout app via singleton
app()->instance('current.region', $region);
View::share('currentRegion', $region);
return $next($request);
}
Region Detection on First Visit
// app/Http/Controllers/RegionDetectController.php
public function __invoke(Request $request): RedirectResponse
{
// 1. Saved region in cookie
if ($saved = $request->cookie('preferred_region')) {
if (Region::where('slug', $saved)->exists()) {
return redirect("/{$saved}/");
}
}
// 2. GeoIP detection via MaxMind GeoIP2
$reader = new \GeoIp2\Database\Reader(storage_path('geoip/GeoLite2-City.mmdb'));
try {
$record = $reader->city($request->ip());
$citySlug = $this->mapCityToRegion($record->city->name);
} catch (\Exception) {
$citySlug = null;
}
$slug = $citySlug ?? Region::where('is_default', true)->value('slug');
return redirect("/{$slug}/")->withCookie(
cookie('preferred_region', $slug, 60 * 24 * 365)
);
}
Getting Regional Content
trait HasRegionalContent
{
public function getRegionalField(string $field, ?Region $region = null): mixed
{
$region ??= app('current.region');
$override = ContentRegionOverride::where('content_id', $this->id)
->where('region_id', $region->id)
->where('field', $field)
->value('value');
return $override ?? $this->$field;
}
}
Usage: $product->getRegionalField('price') — returns regional price or base if no override.
SEO: hreflang and Sitemap
For correct regional indexing, each page must have hreflang tags:
<link rel="alternate" hreflang="ru-RU" href="https://site.ru/msk/catalog/product-1" />
<link rel="alternate" hreflang="ru-KZ" href="https://site.ru/kz/catalog/product-1" />
<link rel="alternate" hreflang="x-default" href="https://site.ru/msk/catalog/product-1" />
Regional sitemap generated separately for each region and included in sitemap_index.xml.
Caching
With Nginx or Varnish, cache key must include region:
# nginx fastcgi_cache
fastcgi_cache_key "$scheme$request_method$host$request_uri";
# URI already contains /msk/ — cache automatically split by region
For Redis cache in Laravel:
$cacheKey = "catalog.{$region->slug}.{$slug}";
Cache::remember($cacheKey, 3600, fn() => $this->buildPage($slug, $region));
Admin Interface
CMS must provide:
- Region switcher in edit interface
- Visual highlight of fields with regional override
- Bulk apply override to product group
- Report: which pages have regional versions, which don't
Timeline and Stages
| Stage | Content | Timeline |
|---|---|---|
| 1 | Data model, migrations, CRUD regions | 2 days |
| 2 | Routing, middleware, GeoIP | 2 days |
| 3 | Regional content in templates | 3 days |
| 4 | SEO: hreflang, sitemap | 1 day |
| 5 | Admin interface | 3 days |
| 6 | Caching, load testing | 2 days |
Total: 2–3 weeks depending on regions count and content volume.







