Virtual Base is designed to address a specific use case: enabling an existing Drupal website to be accessed via additional URLs that include a specified path prefix. This functionality provides a virtual "RewriteBase" layered on top of the website.

For instance, consider a scenario where your website is typically accessed internally (without any RewriteBase) within a private organization. Simultaneously, it is also accessible through an external gateway that uses a fixed URL, with the Drupal website available under a specific path prefix.

Features

Similar to the way path prefixes are used for languages, configuring a path prefix "XXX" in the Virtual Base module allows a route such as "/node/1" to also be accessible at the URL "/XXX/node/1".

Post-Installation

One you install the module, you need to configure the path prefix.
You can use the admin form available at '/admin/config/system/virtual-base'.

You need to add instructions to your .htaccess file to make this module work properly.

Inside the .htaccess file of Drupal, add the following lines, to cope with the path prefix `my_prefix`

# ---
# Virtual Base configuration
# ---

RewriteRule .* - [E=VIRTUAL_BASE:]

RewriteCond %{REQUEST_URI} ^/my_prefix
RewriteRule .* - [E=VIRTUAL_BASE:/my_prefix]

RewriteCond %{REQUEST_URI} ^/my_prefix
RewriteRule ^my_prefix/(.*)$ /$1 [L]

# cope with apache env variable rewritings when having urls redirects
RewriteCond %{ENV:REDIRECT_VIRTUAL_BASE} (.+)
RewriteRule .* - [E=VIRTUAL_BASE:%1]

If you want to enable the module for a specific domain,
you can add a line `RewriteCond %{HTTP_HOST} ^specific\.domain_name\.com`
and replace `specific\.domain_name\.com` with the domain name you want to restrict the module to.

# ---
# Virtual Base configuration
# ---

RewriteRule .* - [E=VIRTUAL_BASE:]

RewriteCond %{HTTP_HOST} ^specific\.domain_name\.com
RewriteCond %{REQUEST_URI} ^/my_prefix
RewriteRule .* - [E=VIRTUAL_BASE:/my_prefix]

RewriteCond %{HTTP_HOST} ^specific\.domain_name\.com
RewriteCond %{REQUEST_URI} ^/my_prefix
RewriteRule ^my_prefix/(.*)$ /$1 [L]

# cope with apache env variable rewritings when having urls redirects
RewriteCond %{ENV:REDIRECT_VIRTUAL_BASE} (.+)
RewriteRule .* - [E=VIRTUAL_BASE:%1]

Project information

  • caution Minimally maintained
    Maintainers monitor issues, but fast responses are not guaranteed.
  • caution Maintenance fixes only
    Considered feature-complete by its maintainers.
  • Project categories: Integrations
  • Created by just_like_good_vibes on , updated
  • shieldStable releases for this project are covered by the security advisory policy.
    There are currently no supported stable releases.

Releases