Dolibarr/dolibarr · error

Error: Wrong $dolibarr_main_url_root_alt value in conf.php…

Error message

Error: Wrong $dolibarr_main_url_root_alt value in conf.php file. We now use a relative path to $dolibarr_main_url_root to build alternate URLs. Value found: ${value} Should be replaced by: ${correct_value}

What it means

During bootstrap, master.inc.php parses the $dolibarr_main_url_root_alt value from conf.php. Since Dolibarr switched to relative alternate URLs, any entry starting with http:// or https:// is rejected: the script prints this error with the suggested relative replacement (the absolute value minus $dolibarr_main_url_root) and exits.

Solutions

  1. Open htdocs/conf/conf.php and locate $dolibarr_main_url_root_alt
  2. Replace each absolute URL with the relative path shown in the error's 'Should be replaced by' line (absolute value minus $dolibarr_main_url_root), e.g. '/custom'
  3. Use one of the documented formats: "/extensions", "/extensions1,/extensions2", or "/../extensions"
  4. Reload the page; if the error persists clear any opcache/PHP cache

Example fix

// before (conf.php)
$dolibarr_main_url_root='http://myserver/dolibarr';
$dolibarr_main_url_root_alt='http://myserver/dolibarr/custom';
// after
$dolibarr_main_url_root='http://myserver/dolibarr';
$dolibarr_main_url_root_alt='/custom';
Defensive patterns

Strategy: validation

Validate before calling

if (preg_match('/^https?:/', $dolibarr_main_url_root_alt)) {
    die('conf.php: $dolibarr_main_url_root_alt must be a path relative to $dolibarr_main_url_root, e.g. /custom');
}

Prevention

When it happens

Trigger: conf.php sets $dolibarr_main_url_root_alt to an absolute URL such as 'http://myserver/dolibarr/custom' or 'https://example.com/extensions'; master.inc.php's preg_match('/^http(s):/') check matches and bootstrapping aborts.

Common situations: Upgrading an old Dolibarr install whose conf.php predates the relative-path convention; copying conf.php snippets from old tutorials; migrations between servers where the old absolute URL format was kept.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of Dolibarr/dolibarr@598aa4bdad (2026-09-14). Data as JSON: /api/errors/c45cd5069e598944. Report an issue: GitHub.

Appendix: source

Thrown at htdocs/master.inc.php:194

$conf->file->instance_unique_id = empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ? '' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id; // Unique id of instance
$conf->file->dol_main_url_root = $dolibarr_main_url_root;	// Define url inside the config file
$conf->file->dol_document_root = array('main' => (string) DOL_DOCUMENT_ROOT); // Define an array of document root directories ('/home/htdocs')
$conf->file->dol_url_root = array('main' => (string) DOL_URL_ROOT); // Define an array of url root path ('' or '/dolibarr')
if (!empty($dolibarr_main_document_root_alt)) {
	// dolibarr_main_document_root_alt can contains several directories
	$values = preg_split('/[;,]/', $dolibarr_main_document_root_alt);
	$i = 0;
	foreach ($values as $value) {
		$conf->file->dol_document_root['alt'.($i++)] = (string) $value;
	}
	$values = preg_split('/[;,]/', (string) $dolibarr_main_url_root_alt);
	$i = 0;
	foreach ($values as $value) {
		if (preg_match('/^http(s)?:/', $value)) {
			// Show error message
			$correct_value = str_replace($dolibarr_main_url_root, '', $value);
			print '<b>Error:</b><br>'."\n";
			print 'Wrong <b>$dolibarr_main_url_root_alt</b> value in <b>conf.php</b> file.<br>'."\n";
			print 'We now use a relative path to $dolibarr_main_url_root to build alternate URLs.<br>'."\n";
			print 'Value found: '.$value.'<br>'."\n";
			print 'Should be replaced by: '.$correct_value.'<br>'."\n";
			print "Or something like following examples:<br>\n";
			print "\"/extensions\"<br>\n";
			print "\"/extensions1,/extensions2,...\"<br>\n";
			print "\"/../extensions\"<br>\n";
			print "\"/custom\"<br>\n";
			exit;
		}
		$conf->file->dol_url_root['alt'.($i++)] = (string) $value;
	}
}

// Load the main includes of common libraries
if (!defined('NOREQUIREUSER')) {
	require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // Need 500ko memory
}

View on GitHub (pinned to 598aa4bdad)