- 🇸🇰Slovakia lubwn
In my case I was getting error because Drupal is behind reverse proxy. My problem is that it is a bunch of different servers all pointing to different subdirectories, while I do not have an access to the main server where the main website lives.
So in my case I did not need to "remove" the subdirectory but ADD the subdirectory instead. Which worked, but also resulted in TrustedRedirect errors.
My settings.php file is:
$trim_path = '/subdirectory'; if (isset($GLOBALS['request'])) { $request = $GLOBALS['request']; if ($request->server->get('SCRIPT_NAME') == "/index.php") { $request->server->set('SCRIPT_NAME', '/subdirectory/index.php'); $request_uri = $trim_path . substr($request->server->get('REQUEST_URI'), 1); $request->server->set('REQUEST_URI', $request_uri); } }
To fix trustedRedirect errors I used rather stupid jquery front-end fix, but it works:
/* Fix trustedRedirectResponse */ $( document ).ajaxComplete(function (event, xhr, settings) { $("a").each(function() { $(this).attr("href", $(this).attr("href").replace("edit?destination=/node/", "edit?destination=/subdirectory/node/")); }); });
I had trouble in ajaxified views, which lead to wrong redirects but it was all in GET parameter, so this basicly just replaces href attribute with proper URL.
- 🇲🇩Moldova gzveri
#76 is the only solution, clean and worked perfectly for installing Drupal10 in a subfolder of root folder /public_html for a primary domain on linux deluxe shared account on godaddy.
- 🇫🇷France selinav
#76 works for me with Drupal10 with hostinger.
I have adapted the path :
if (isset($GLOBALS['request']) and
'/web/index.php' === $GLOBALS['request']->server->get('SCRIPT_NAME')) {
$GLOBALS['request']->server->set('SCRIPT_NAME', '/index.php');
}