---
name: routing-multisubdomain
description: How routing works in the Mediknode/Unified platform — multi-subdomain (frontend vs backend), multi-instance per-domain branching, and named routes. Use when adding/editing routes in routes/web.php, debugging 404s, writing tests that hit URLs, or working across client instances.
---

# Multi-subdomain & multi-instance routing

## Two subdomains
`routes/web.php` splits every route into:
- **Frontend** (`config('app.frontend_sub_domain')`, e.g. `events.*`): public event pages, 7-step registration, abstract submission, payments.
- **Backend** (`config('app.backend_sub_domain')`, e.g. `my-events.*`): admin dashboard, participant/event management, campaigns.

Groups are declared with:
```php
Route::domain($frontendSubDomain.'.'.$domain)->namespace('App\Http\Controllers\Frontend')->group(function () { ... });
Route::domain($backendSubDomain.'.'.$domain)->namespace('App\Http\Controllers\Backend')->group(function () { ... });
```
Put your route in the **correct subdomain group** or it won't resolve.

## Multi-instance
The file branches on the active domain:
```php
if ($domain == 'mediknode.com' || $domain == 'mediknode.local') { ... }
```
Each instance (`.env.*`, selected by server port in `bootstrap/app.php`) gets its own branch. Reuse an existing branch as the template when adding an instance.

## Rules
- **Always name routes** (`->name('participants.index')`). Multi-step forms use `step1`–`step7` suffixes.
- The participants module is mid-migration: old `/manage/` (ManageController) coexists with new `/participants/` (ParticipantController). Don't break `/manage/`.
- `robots.txt` is served per-instance inline in the route group; backoffice is no-indexed via `NoIndexBackend`.

## Testing URLs (critical)
A bare `/path` 404s in tests because routes are domain-scoped. Build the host:
```php
$base = 'http://'.config('app.backend_sub_domain').'.'.config('app.domain');
$this->actingAs($admin)->get($base.'/events/'.$event->id.'/participants');
```
Use the frontend subdomain for frontend routes.

See also: [[project-conventions]], [[testing-conventions]].
