There are a few outdated methods floating around the Internet on loading Drupal 8 from a subdirectory. One day, perhaps this article will suffer the same fate.
Goal:
Our Drupal install is in /drupal, and that's what I'm using in the below examples. Adjust accordingly.
1. In the web root of the account, create an .htaccess file which contains the following:
RewriteRule ^$ drupal/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ drupal/$1 [L]
2. In the .htaccess file that is in the root directory of the Drupal installation, un-comment the RewriteBase line and add your subdirectory to it.
RewriteBase /drupal
Many actions will now work when accessed at the root domain name, but in some places you'll likely get the Redirects to external URLs are not allowed by default, use \Drupal\Core\Routing\TrustedRedirectResponse for it WSOD.
3. Add the following to the settings file in /drupal/sites/default/settings.php
:
if (isset($GLOBALS['request']) and '/drupal/index.php' === $GLOBALS['request']->server->get('SCRIPT_NAME')) {
$GLOBALS['request']->server->set('SCRIPT_NAME', '/index.php');
}
Leave a comment if you encounter problems, or have suggestions for a better method.
Add new comment