If the default config has URLs set as frontend ones, you may experience the problem where the admin subdomain redirects to the frontend domain.
Base URL
Note: The base URL for Static View Files and for User Media Files may be different in your setup.
In order not to break the frontend URL, make sure you set up your multi-store URLs in their own store views (Stores > Configuration > General > Web).
The last step is to configure Magento to actually use a subdomain as access to it.
Go to:
Stores > Configuration > Advanced > Admin
Admin Base URL
Set the Use Custom Admin URL to Yes and fill in the subdomain.
Note: Make sure your DNS is properly configured for your frontend as well as for the admin subdomain. You could use the same IP for both or separate IP addresses if you plan on using a separate server for it.
Then, clear the cache and try your new setup now, preferably in the incognito tab. (Or you may need a deploy…)
Did it work?
If it didn’t, please continue reading.
Cookies
In some cases, your cookies might be blocking you from accessing the new subdomain.
Under the default store view, make sure the cookie domain matches your domain. But also make sure you set the proper domain in your website scope.
Is it working?
If not, you may need to check your environment setup.
Environment
So, here are some questions that could help you.
Have you tried it in the incognito tab? Or flushing the browser cache?
Do you have a load balancer? Is the new subdomain flowing through the load balancer?
Are you on Nginx? – Check your proxies.
Or Apache maybe? – Check your .htaccess files.
Are DNS settings ok? Are the domains pointing to the right addresses?
Do you get redirected? – Try one of the redirect tracing tools for your browser.
admin.domain.com
, do you have one?https://github.com/magento/magento2/issues/12354
or rewrite rule in server config.