有人知道如何使用 ddev-local 为 Magento 2 多站点设置 $MAGE_RUN_CODE 和 $MAGE_RUN_TYPE 变量吗? 我已将新域添加到 .ddev/config.yaml 中的 extra_hostnames 变量中 - 但现在我需要告诉 nginx docker 容器在请求 newstorefront.ddev.site 域时为 magento 店面提供服务。 有任何想法吗?谢谢。
我通过覆盖 .ddev/nginx_full/nginx-site.conf 并将以下行添加到服务器块的顶部(就在它定义的位置之前)来实现此功能:
if ($mage_run_code = '') {
现在一切正常。
谢谢
在您的项目文件夹中
web_environment:
- MAGE_RUN_CODE =someval
- MAGE_RUN_TYPE =someotherval
添加包含以下内容的
MAGENTO_ROOT_FOLDER/.ddev/nginx_full
:magento-stores.conf
接下来,打开项目的
map $http_host $mage_run_code {
default '';
store1.ddev.site storecode1;
store2.ddev.site storecode2;
store3.ddev.site storecode3;
}
并添加其他主机名:
MAGENTO_ROOT_FOLDER/.ddev/config.yaml
来源:https://github.com/jellesiderius/ddev-magento2-setup?tab=readme-ov-file#setting-up-multistore-configuration