Magento – How to setup a subdomain for admin panel in magento 2

admin-panelmagento2subdomain

Today i had tried to use the sub domain like admin.domain.com for admin panel by setting the custom url for admin panel in system -> config -> Advanced -> admin -> admin base url -> Custom Admin URL

After changing the url with sub domain. Unable to login admin panel by sub domain.
I'm getting too many redirect error. sometimes it going to base domain like www.domain.com. Even after clearing the cache problem still not solved. Anyone help me Regarding this issue, that will be highly appreciated.

Note: I had already tried the solutions on the similar post but nothing will work. And i'm using magento 2.2.6

Best Answer

Usually, when you want a separate Admin Base URL it also means you need an admin instance (which separate with your webserver stacks), and in that case, I suggest you do the following approach:

  • Set your admin URLs as the global (Default store view) config in Config > General > Web (for e.g: admin.example.com)
  • Set your other store URLs in the corresponding Website configurations (e.g US, UK...etc)
  • Check and change the Cookie domain for admin URL instance (Global one) to your wanted sub-domain.
  • Find and fix all issues related to admin base URLs (Magento 2 acknowledge for e.g WYSIWYG media URL)

Magento 2 has the functionality to use separate Admin URL, but unfortunately, based on my own experience it won't help :(

Cheers,