elgentos/module-baseurlpath
Composer 安装命令:
composer require elgentos/module-baseurlpath
包简介
Allow Magento config to have a base url path instead of root without moving Magento 2 into a subdirectory
README 文档
README
Magento 2 - Elgentos_BaseUrlPath
Allow setting up a base url in system config other than root.
If you want to add https://my.domain.tld/mypseronalurl/ after the baseurl Magento currently doesn't allow this.
You are left with adding the storecode to the path or creating subdirectories with extra files.
This can get ugly if you just want to add language codes(other than locale-codes) to your domain,
for example https://my.domain.tld/en/ and https://my.domain.tld/nl/
Installation: part 1 - Module via composer
Install the module via composer by running
composer require elgentos/module-baseurlpath bin/magento module:enable Elgentos_BaseUrlPath bin/magento cache:flush
Installation: part 2 - Nginx MAGE_RUN_CODE
Make sure you setup your MAGE_RUN_CODE mapping correctly. By default in Nginx this is only done based on $host name.
We will add the $request_uri to the mapping.
# https://{host}/{language}/{magento_request}/ # Most specific match goes first map $host$request_uri $mageRunCode { hostnames; default default; ~other.domain.tld/nl/ other_nl; ~other.domain.tld other_en; ~my.domain.tld/en/ site_en; ~my.domain.tld site_nl; } # fastcgi section fastcgi_param MAGE_RUN_CODE $mageRunCode;
Nginx without mapping
Or if Nginx mapping isn't available for you.
# https://{host}/{language}/{magento_request}/ # Most specific match goes last # this one is untested thought(sorry for that) set $mageRunCode "default"; if ($host$request_uri ~ other.domain.tld/) { set $mageRunCode "other_en"; } if ($host$request_uri ~ other.domain.tld/nl/) { set $mageRunCode "other_nl"; } if ($host$request_uri ~ my.domain.tld/) { set $mageRunCode "site_nl"; } if ($host$request_uri ~ my.domain.tld/en/) { set $mageRunCode "site_en"; }
Configuration
After installation goto Stores / Configuration -> General / Web -> Base URLs ((Un)Secure)
My strong advise setting these settings on website or store view level because making errors could potentially lock you out from the admin pages
Store 1: site_en
Update your base url to https://my.domain.tld/en/

Store 2: site_nl
Update your base url to https://my.domain.tld/nl/

Static content and media
To make static content work with these settings, you explicitly need to setup these paths to the root(/) of your site.
Authors
elgentos/module-baseurlpath 适用场景与选型建议
elgentos/module-baseurlpath 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.85k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2020 年 10 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 elgentos/module-baseurlpath 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 elgentos/module-baseurlpath 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4.85k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2020-10-01
