Skip to main content
Drupal is a registered trademark of Dries Buytaert
EOL Warning: Drupal 11.0 has reached end of life and no longer receives security updates. Release: Private content 3.1.0 Minor update available for module private_content (3.1.0). Release: Webform Analysis 2.0.0 Major update available for module webform_analysis (2.0.0). Usage Milestone: Focal Point Module focal_point crossed 1,000 active installs. Release: Opensolr Search 4.3.1 Minor update available for module opensolr_search (4.3.1). Release: Opensolr Search 4.3.0 Minor update available for module opensolr_search (4.3.0). Release: Palette🎨 1.0.3 Minor update available for module canvas_palette (1.0.3). Release: Opensolr Search 4.2.4 Minor update available for module opensolr_search (4.2.4). Release: Changelogify 1.8.0 Minor update available for module changelogify (1.8.0). Release: Opensolr Search 4.2.3 Minor update available for module opensolr_search (4.2.3).

This module allows your Drupal site to be accessible through additional URLs that include a configurable path prefix. For example, a page normally at "/node/1" could also be accessed at "/your-prefix/node/1".

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]

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Jul 2026
Latest release
1 month ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Core Release date
1.0.0-alpha5 Pre-release 10–11 Jul 15, 2026