在子域上访问 Magento Admin

Access Magento Admin on Subdomain

我在 Magento 2 上有一个 运行 商店,它有多个我可以在前端毫无问题地访问的网站,例如:

https://siteone.mymagestore.com
https://sitetwo.mymagestore.com
https://sitethree.mymagestore.com
.
.
.

但是当我尝试以同样的方式访问管理面板时,它会将我重定向到主商店 URL,例如:

https://siteone.mymagestore.com/admin -> Redirects to https://www.mymagestore.com/admin

我怎样才能允许像 https://siteone.mymagestore.com/admin 这样的 URL 访问 Magento 管理面板?

我尝试了很多方面来解决这个问题,但似乎没有任何帮助。如有任何帮助,我们将不胜感激。

不幸的是,目前仅 Magento 无法做到这一点。 Magento 允许您指定自定义管理员 URI(例如,让您的商店位于 siteX.magestore.com,管理员位于 admin.magestore.com)。

如果您需要更多信息,可以查看this issue on magento github。这是两年前报告的 Magento 上的错误行为,已在 2.1、2.2、2.3 上得到确认,但尚未修复。

作为解决方法,在错误报告中我发现了这个:

This module fixed it for us: METMEER/magento2-multi-store-fix!

您可以尝试安装此模块。

这可以通过在 Magento\Framework\Url

中添加以下代码来完成

getUrl() 函数 - 在末尾添加

替换:

$this->cacheUrl[$cacheKey];

与:

$finalUrlArray = explode('://', $this->cacheUrl[$cacheKey]);
$finalUrl = $finalUrlArray[0].'siteone.'.$finalUrlArray[1];
return $finalUrl;