CA_URL_ROOT wrong if using Apache Alias

edited September 28 in Feedback

When having Alias directives configured to point at different CA providence installations, the path in CA_URL_ROOT is replaced incorrectly.

Here's an example from our setup (apache config snippet):

DocumentRoot /var/www/providence
Alias /pb /var/www/providence_pb
<Directory /var/www/providence_pb>
    Order allow,deny
    allow from all

When opening providence_pb as "https://myserver/pb", some URL roots are incorrectly rendered as "_pb/".

I assume the following code in "*/app/helpers/post-setup.php@55*" is responsible for this?

if (!defined("__CA_URL_ROOT__")) {
        define("__CA_URL_ROOT__", str_replace(isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : '', '', __CA_BASE_DIR__));

I guess related variables in $_SERVER at that time are:

[DOCUMENT_ROOT] => /var/www/providence
[CONTEXT_DOCUMENT_ROOT] => /var/www/providence_pb

However, if replacing $_SERVER['DOCUMENT_ROOT'] with $_SERVER['CONTEXT_DOCUMENT_ROOT'], CA_URL_ROOT will be '' (empty) - triggering an error that suggest to hard-code the root:

It looks like the __CA_URL_ROOT__ variable in your setup.php is not set correctly. Please try to set it to "/pb". Note that paths are case sensitive.

Setting the CA_URL_ROOT to "/pb" (in /setup.php) is exactly what fixed the problem, but that error message didn't appear until I switched to "CONTEXT_DOCUMENT_ROOT" - and it took me 2 hours of chasing down rabbit holes to find out what the devil was happening to my URL path.

I admit I haven't tested this on latest development branch.

Maybe it's already fixed there?


  • The code in post-setup.php tries to divine the path using environment variables passed to it. CONTEXT_DOCUMENT_ROOT contains paths with respect to aliases. It is not available in all environments and should only differ from DOCUMENT_ROOT (which is more consistently available) when aliases are employed.

    We should add code to utilize CONTEXT_DOCUMENT_ROOT when it is available. All systems running Apache 2.4 should return it, so the change should cover most of the odd cases where aliases are used.

    Thanks for pointing out this gap.

Sign In or Register to comment.