Domain Route Access collection page
Domain Route Access form

The Domain Route Access UI module provides a new configuration entity to manage access to existing routes by domain from back office.

Use case example:
You have two domains example1.com and example2.com and you want users to be able to create their accounts only on the example2.com domain. With Domain Route Access, you can achieve this by adding an access check on the user.register route so that it is only accessible on example2.com.

Configuration

To add new Domain Route Access check:

Option 1: Via Domain Route Access config entity

  1. Go to Domain Route Access config entity collection page: /admin/config/domain/route-access
  2. Click Add new Domain Route Access action link
  3. Fill in the new Domain Route Access config entity form and click Save
  4. Clear Drupal cache

For each Domain Route Access configuration entity, you could:

  • Select the route for which you want to check access by domains
  • Select the allowed domains on which the route should be accessible
  • Enable/Disable the Domain Route Access check


Option 2: Using existing _domain route requirement

my_module.custom_route:
  path: '/foo/bar'
  defaults:
    _controller: 'Drupal\my_module\Controller\BarsController'
  requirements:
    _permission: 'view bars content'
    _domain: 'domain1_id+domain2_id'

Additional Requirements

Domain Route Access requires Domain contrib module.

Project information

Releases