Domain

The Domain module suite lets you share users, content, and configuration across a group of domains from a single installation and database.

domain
11,435 sites
115
drupal.org

概要

Domain モジュールスイートは、Drupal 向けの包括的なマルチドメイン管理ソリューションを提供します。管理者は単一の Drupal インストール内で複数のドメインを登録し、ドメイン間でコンテンツとユーザーを共有し、ドメイン固有の設定とアクセス制御を提供できます。

このモジュールは、ドメインベースのコンテンツアクセス、ドメイン固有の設定オーバーライド、ワイルドカードパターン対応のドメインエイリアス、SEO 向けの正規 URL 管理、クロスドメインログインサポートなどの機能をサポートしています。ドメインレコードは設定エンティティとして保存されるため、サイト設定の一部としてエクスポート可能です。

このスイートには、Domain(コア機能)、Domain Access(コンテンツアクセス制御)、Domain Alias(ホスト名マッピング)、Domain Config(ドメインごとの設定)、Domain Config UI(設定用管理インターフェース)、Domain Content(ドメイン別コンテンツ概要)、Domain Source(正規 URL 管理)の複数のサブモジュールが含まれています。

Features

  • 単一の Drupal インストール内で、一意のホスト名とマシン名を持つ複数のドメインを登録
  • HTTP リクエストに基づいてアクティブなドメインを決定するドメインネゴシエーションシステム
  • ドメインごとに http、https、または可変 URL スキームをサポート
  • 共有 Cookie 設定によるクロスドメインユーザーログイン
  • コンテンツタイプごとに設定可能な権限を持つドメインベースのコンテンツアクセス制御
  • ワイルドカードパターンサポート(例:*.example.com)とリダイレクトオプションを持つドメインエイリアス
  • サイト名や設定を含む任意の Drupal 設定に対するドメインごとの設定オーバーライド
  • 言語対応のドメイン設定オーバーライド
  • ドメイン間で一貫したリンク生成のための正規 URL 管理(Domain Source)
  • 開発ワークフロー向けのドメイン環境マッピング(local、development、staging、testing)
  • ドメイン固有の値に対する Token サポート
  • body タグに追加されるドメインごとのカスタム CSS クラス
  • ドメインベースのアクセス制御とフィルターを持つ Views 統合
  • ドメイン管理操作用の Drush コマンド
  • ドメインナビゲーション、切り替え、サーバー情報表示用のブロックプラグイン
  • ドメインベースのブロック表示用 Condition プラグイン

Use Cases

Multi-brand Website

Manage multiple brand websites from a single Drupal installation. Each brand gets its own domain (brand1.com, brand2.com) with separate site names, themes (via Domain Theme Switch contrib module), and content visibility settings while sharing the same user base and administrative interface.

Multi-region Deployment

Run region-specific websites (us.example.com, eu.example.com) from one codebase. Use Domain Config to customize site name, contact information, and regional settings per domain. Use Domain Access to control which content appears on which regional site.

Development Workflow

Use Domain Alias to map development environments (example.local, example.dev.cloudhost.com, example.staging.cloudhost.com) to their production counterparts. Set environments so links are correctly rewritten for each stage of development without modifying domain records.

Microsites

Create microsites for campaigns, events, or product launches that share the main site's content management but appear as separate domains. Use Domain Access to assign specific content to microsites while keeping everything manageable from a central admin.

Intranet and Public Site

Run both a public website and a private intranet from the same installation. Use Domain Access permissions to control which content types and nodes appear on each domain, with separate user roles and permissions per domain.

SEO and Canonical URLs

Use Domain Source to ensure content that appears on multiple domains always has consistent canonical URLs. This prevents duplicate content issues and consolidates search engine rankings to your preferred domain.

Franchise or Dealer Networks

Manage a network of franchise or dealer websites where each location has its own domain. Share common content (product catalog, policies) across all sites while allowing location-specific customization and content.

Tips

  • Domain records are configuration entities, so they are exported with your site configuration and can be managed in version control.
  • Always add url.site to required_cache_contexts when using Domain Config to ensure proper cache segmentation.
  • Use environment-based aliases for development workflows to avoid modifying production domain records during development.
  • The domain switcher block is useful during development but should be restricted in production to admin users only.
  • When deleting domains, you'll be prompted to reassign content - plan your content migration strategy before deletion.
  • Use drush domain:generate for quickly setting up test domains during development.
  • Domain Source rewrites links but does not issue redirects. If you need redirects, configure them in Domain Alias or use a separate redirect module.
  • For large multi-domain sites, consider using per-bundle node access grants (experimental feature in Domain Access) for better performance.
  • Token support in CSS classes allows dynamic classes like domain-[domain:machine-name] for domain-specific theming hooks.

Technical Details

Admin Pages 11
Domains /admin/config/domain

View and manage all registered domain records. Lists domains with their hostname, name, scheme, status, and default flag. Provides inline actions to enable, disable, or set default domains. The currently active domain is shown in boldface.

Add domain record /admin/config/domain/add

Create a new domain record with hostname, name, URL scheme, and status settings.

Domain settings /admin/config/domain/settings

Configure global settings for the Domain module including character support, www prefix handling, CSS classes, and accessible paths for inactive domains.

Domain Access settings /admin/config/domain/domain_access

Configure how Domain Access fields are displayed and control node access behavior.

Domain aliases /admin/config/domain/alias/{domain}

Manage aliases for a specific domain. Aliases define unique domains or patterns that map to existing domain records, with support for wildcards and redirect options.

Add domain alias /admin/config/domain/alias/{domain}/add

Create a new alias for a domain with pattern, redirect, and environment settings.

Domain config forms /admin/config/domain/config-ui

Configure which configuration forms can have domain-specific overrides and which should be excluded.

Saved configuration /admin/config/domain/config-ui/list

View all saved domain-specific configuration overrides with options to inspect, enable/disable, or delete them.

Domain Source settings /admin/config/domain/domain_source

Configure which routes and paths should be excluded from Domain Source link rewrites.

Affiliated content /admin/content/domain-content

Review content by assigned domain. Provides Views-based content overview pages filtered by domain assignment.

Affiliated editors /admin/content/domain-editors

Review users by assigned domain. Provides Views-based user overview pages filtered by domain editor assignments.

権限 31
Administer all domain records

View, create, edit, and delete domain records. Allows all permissions for the module. Restricted access.

Access inactive domains

Access domain URLs for domains marked as inactive. Restricted access.

Assign additional administrators to assigned domains

Allows assigning administrators to domains the user has access to. Restricted access.

Create domain records

Allows creating new domain records. Restricted access.

Edit assigned domain records

Edit domain records assigned to the user. Restricted access.

Delete assigned domain records

Delete domain records assigned to the user. Restricted access.

Access the domain navigation block

Allows viewing the domain navigation block.

Access the domain switcher block

Allows viewing the domain switcher block. Restricted access.

View assigned domains in the administration list

View only the domains assigned to the user in admin lists.

View all registered domains in the administration list

View all registered domains regardless of assignment.

View debugging information for domain handling

View detailed domain server information block. Restricted access.

View published domain entities

Allows users to view individual domain entities when needed for rendering, without granting access to the full list.

Administer all domain aliases

Full administration access to all domain aliases. Restricted access.

Create domain aliases for assigned domains

Create aliases for domains assigned to the user. Restricted access.

Edit domain aliases for assigned domains

Edit aliases for domains assigned to the user. Restricted access.

Delete domain aliases for assigned domains

Delete aliases for domains assigned to the user. Restricted access.

View aliases for assigned domains

View aliases for domains assigned to the user.

Assign additional editors to assigned domains

Allows assigning content editors to domains. Restricted access.

Assign additional editors to any domains

Allows assigning editors to any domain. Restricted access.

Publish to any domain

Allows publishing content to any domain.

Publish content to any assigned domain

Allows publishing content to domains assigned to the user.

Create any content on assigned domains

Create any content type on assigned domains.

Edit any content on assigned domains

Edit any content on assigned domains.

Delete any content on assigned domains

Delete any content on assigned domains.

View unpublished content on assigned domains

View unpublished content on assigned domains. Restricted access.

Administer Domain Config UI settings

Allows administrators to determine what forms are available for domain-specific configuration. Restricted access.

Set the default configuration for all sites

Allows domain administrators to set the default value for a configuration. Restricted access.

Translate domain-specific configurations

Allows domain administrators to use language-specific configuration forms. Restricted access.

Manage domain-specific configurations

Allows domain administrators to use configuration forms specific to their managed domains. Restricted access.

Access domain content pages

Access the affiliated content overview pages.

Access domain editors pages

Access the affiliated editors overview pages.

Hooks 4
hook_domain_request_alter

Allows modules to modify the active domain during request negotiation.

hook_domain_validate_alter

Allows modules to modify or add validation errors for domain hostnames.

hook_domain_references_alter

Allows modules to modify the domain reference options available in entity reference fields.

hook_domain_source_exclude_routes_options_alter

Allows modules to modify the list of routes that can be excluded from Domain Source link rewrites.

Drush Commands 17
drush domain:list

List active domains for the site.

drush domain:add

Add a new domain to the site.

drush domain:delete

Delete a domain from the site.

drush domain:default

Sets the default domain.

drush domain:disable

Deactivates a domain.

drush domain:enable

Activates a domain.

drush domain:name

Changes a domain's label.

drush domain:scheme

Changes a domain's URL scheme.

drush domain:test

Tests domains for proper HTTP response.

drush domain:info

List general information about the domains on the site.

drush domain:replace

Replace strings in domain hostnames.

drush domain:generate

Generate domains for testing.

drush domain-alias:list

List all domain aliases.

drush domain-alias:add

Add a new domain alias.

drush domain-alias:delete

Delete a domain alias.

drush domain-alias:delete-bulk

Delete multiple aliases.

drush domain-alias:update

Update a domain alias.

Troubleshooting 8
Cross-domain login not working

Set the cookie_domain value in sites/default/services.yml to match the root hostname of your sites (e.g., cookie_domain: '.example.com'). This requires all domains to share a common parent domain.

Configuration changes not appearing on domains

Add url.site to required_cache_contexts in services.yml. Clear caches after making the change. Ensure any config overrides follow the correct naming pattern: domain.config.DOMAIN_ID.config_name

AJAX errors when using entity reference fields across domains

Enable CORS in services.yml by setting cors.config.enabled to true. Configure allowedOrigins to include your domains or use ['*'] for all origins.

Domain redirects not working

Ensure all domains and aliases are added to trusted_host_patterns in settings.php. Domain will refuse to redirect to hosts not in the trusted list.

Content not appearing on expected domains

Check the Domain Access field values on the content. If using Domain Access, rebuild node access permissions at /admin/reports/status/rebuild after configuration changes.

Cannot create domain - hostname validation fails

Ensure the Test server response checkbox is unchecked if the domain DNS is not yet configured. Alternatively, ensure your server can reach the domain hostname via HTTP.

Domain aliases not matching

Check the sort order of aliases. More specific patterns should have lower weights. Wildcard matching follows a specific precedence order documented in the Domain Alias README.

Views not filtering by domain correctly

Ensure the correct Views access handler is configured (domain, domain_access_content, or domain_access_editor). Add appropriate contextual filters or arguments for domain fields.

Security Notes 7
  • All permissions marked 'restrict access' are considered sensitive and should only be granted to trusted roles.
  • Enabling CORS for cross-domain AJAX has security implications - review the documentation before enabling.
  • The 'access inactive domains' permission allows bypassing domain visibility restrictions - grant only to administrators.
  • Domain configuration overrides can change security-sensitive settings - restrict 'use domain config ui' permission appropriately.
  • Cross-domain login shares session cookies across domains - ensure all domains are under your control before enabling.
  • Always configure trusted_host_patterns in settings.php to prevent redirect attacks to malicious domains.
  • The 'administer domains' permission grants full control over all domain functionality - equivalent to site administrator access for domain operations.