FILE: app/Http/Kernel.php

Find the existing 'web' middleware group. Keep all existing middleware in the
same order and append the AMC middleware AFTER SubstituteBindings:

'web' => [
    \App\Http\Middleware\EncryptCookies::class,
    \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
    \Illuminate\Session\Middleware\StartSession::class,
    // \Illuminate\Session\Middleware\AuthenticateSession::class,
    \Illuminate\View\Middleware\ShareErrorsFromSession::class,
    \App\Http\Middleware\VerifyCsrfToken::class,
    \Illuminate\Routing\Middleware\SubstituteBindings::class,
    \App\Http\Middleware\AmcSubdomainOnly::class,
],

Do not replace the whole Kernel.php with this snippet. Add only the final
middleware line to the existing web group.
