urlManager with dynamic subdomain

I have an application, which uses a domain name of


it hosts the the default application with all the default routes and stuff

Also I have configured urlManager to handle a dynamic subdomain


The requests to this domain is handled by the same application (i.e. frontend/web) but configured with urlManager rules


'protocol://<client>.domain.com/r/<token>' => 'public/response' // Handles requests to ****.domain.com

'<controller>/<action>' => '<controller>/<action>' // Handles the default application app.domain.io

So the problem is this, if a user removes the "r/<token>" part from the URL, then the request is handled as it was sent to


and the "site/login" page is opened (because login is required for the application)

But in fact a 404 error should be shown.

This can be achieved by using $enableStrictParsing, but by enabling it, all other routes of the application stop working (i.e. default route site/index, module/controller/action , etc)

What about this?

'protocol://<client>.domain.com/r/<token>' => 'public/response',

'protocol://<client>.domain.com' => 'public/error',

'<controller>/<action>' => '<controller>/<action>',