gerritvanaaken/multidomain-router 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gerritvanaaken/multidomain-router

Composer 安装命令:

composer require gerritvanaaken/multidomain-router

包简介

A Kirby plugin for routing and managing multiple domains in a single Kirby installation.

README 文档

README

A Kirby plugin for routing and managing multiple domains within a single Kirby installation.

How It Works

The plugin automatically handles routing for multiple domains and replaces URLs in the rendered HTML output:

  1. Routing: Intercepts all requests and maps them to the correct content folder based on the domain
  2. URL Replacement: In the rendered output, all URLs are intelligently trimmed:
    • links within current domain (same folder): Converted to relative paths
    • links to sibling domain (different folder): Converted to the full absolute URLs

Installation (1/3)

via composer

To install the Multidomain Router plugin via composer, run:

composer require gerritvanaaken/multidomain-router

Make sure you are in the root directory of your Kirby project when running this command.

After installation, the plugin will be available at site/plugins/multidomain-router/. You can then continue with the configuration as described below.

manually

Download and copy the full plugin folder into site/plugins/.

Domain Configuration (2/3)

There are two methods to configure your domains:

Method A: Config File (Recommended)

Add the domain configuration directly in your site/config/config.php:

<?php

return [
    'praegnanz.multidomain-router.sites' => [
        [
            'domain' => 'https://example-domain-one.com',
            'folder' => 'example-domain-one',
            'error' => 'example-domain-one/error' //optional
        ],
        [
            'domain' => 'https://example-domain-two.com',
            'folder' => 'example-domain-two',
            'error' => 'example-domain-two/error' //optional
        ]
    ]
];

Configuration Options:

  • domain (required): Full URL including protocol, no trailing slash
  • folder (required): Content folder name, without any slashes
  • error (optional): Path to custom error page (e.g. 'folder-name/error')

Method B: Panel Configuration (Fallback)

If you prefer to configure domains through the Panel:

  1. Add the Multidomain config to your site/blueprints/site.yml, using extend:
title: Site

tabs:
  content:
    label: Seiten
    icon: page
    sections:
      pages:
        type: pages
  
  multidomains:
    extends: multidomain-router
  1. Refresh the Panel and configure your domains:
    • Open the Panel and go to Site Settings
    • Locate the "Multidomain" section
    • Click "+ Add" to configure a new site
    • Enter the folder name (e.g. example-domain-one)
    • Enter the domain (e.g. https://example-domain-one.com)
    • Optionally select an error page
    • Don't forget to save! ✓

Note: If domains are configured in the config file (Method A), the Panel configuration will be ignored.

Folder creation (3)

To create the required content folders for each domain, follow these steps:

  1. Navigate to your site's content directory (usually site/content in your Kirby installation).

  2. Create a new folder for each domain.

    • The folder name must exactly match the folder value you set in your multidomain configuration.
    • For example:
      site/content/example-domain-one/
      site/content/example-domain-two/
      
  3. Add content to each folder as usual.

    • Each folder will represent the homepage and pages for that particular domain.
    • The typical structure inside a folder:
      site/content/example-domain-one/home.txt
      site/content/example-domain-one/1_rooms/rooms.txt
      site/content/example-domain-two/1_rooms/1_penthouse/room.txt
      
    • Add your regular Kirby pages (folders ending in .txt/subfolders) inside the domain folder as you would for a single-site setup.

Tips:

  • If a domain has a custom error page, make sure to create the corresponding error page in the respective folder, e.g.:
    site/content/example-domain-one/error/default.txt
    site/content/example-domain-two/error/default.txt
    
  • Folder names and structure should remain consistent with your configuration to ensure correct routing.

That's it! Each domain will serve content from its respective folder.

Examples for URL replacements

On https://hotel-kirby.de

  • /hotel-kirby/room/room
  • /restaurant-kirby/lunchhttps://restaurant-kirby.de/lunch
  • https://hotel-kirby.de/hotel-kirby/room/room

On https://restaurant-kirby.de

  • /restaurant-kirby/lunch/lunch
  • /hotel-kirby/roomhttps://hotel-kirby.de/room
  • https://restaurant-kirby.de/restaurant-kirby/lunch/lunch

License

MIT

Author

Gerrit van Aaken (gerrit@praegnanz.de)

gerritvanaaken/multidomain-router 适用场景与选型建议

gerritvanaaken/multidomain-router 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 57 次下载、GitHub Stars 达 9, 最近一次更新时间为 2025 年 11 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「routing」 「multidomain」 「kirby」 「kirby-plugin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 gerritvanaaken/multidomain-router 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 gerritvanaaken/multidomain-router 我们能提供哪些服务?
定制开发 / 二次开发

基于 gerritvanaaken/multidomain-router 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 57
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 24
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-04