diff --git a/config/vufind/httpd-vufind.conf b/config/vufind/httpd-vufind.conf
index a42e5a29f782d00811f09764792d1adac8311dd6..3cfdfea49be3d89febaaa05f3b16154cb3bd0222 100644
--- a/config/vufind/httpd-vufind.conf
+++ b/config/vufind/httpd-vufind.conf
@@ -61,4 +61,9 @@ Alias /vufind /usr/local/vufind/public
   # Multiple modules may be specified separated by commas.  This mechanism can be used to override
   # core VuFind functionality without modifying core code.
   #SetEnv VUFIND_LOCAL_MODULES VuFindLocalTemplate
+
+  # This line overrides the detection of VuFind base directory. By default it is determined from
+  # the location of the index.php file, but in case it is e.g. symlinked or there is another reason
+  # to define the path manually, you can uncomment and modify this line.
+  #SetEnv VUFIND_APPLICATION_PATH /usr/local/vufind
 </Directory>
diff --git a/module/VuFindTheme/Module.php b/module/VuFindTheme/Module.php
index 26b0d39276d8b8a3c79a52b20189c98ac4035e2f..a154caabd1708a1e4d42303572c6dc21d8b0ae1d 100644
--- a/module/VuFindTheme/Module.php
+++ b/module/VuFindTheme/Module.php
@@ -100,6 +100,6 @@ class Module
      */
     public static function getThemeInfo()
     {
-        return new ThemeInfo(realpath(__DIR__ . '/../../themes'), 'bootprint3');
+        return new ThemeInfo(realpath(APPLICATION_PATH . '/themes'), 'bootprint3');
     }
 }
diff --git a/public/index.php b/public/index.php
index ee18e67132b273a91f1d939da5e401cb0c052a88..39e0afbcece92586874933fcdd27c2c92bb3d477 100644
--- a/public/index.php
+++ b/public/index.php
@@ -13,15 +13,25 @@ if (!empty($xhprof) && extension_loaded('xhprof')) {
 
 // Define path to application directory
 defined('APPLICATION_PATH')
-    || define('APPLICATION_PATH', dirname(__DIR__));
+    || define(
+        'APPLICATION_PATH',
+        (getenv('VUFIND_APPLICATION_PATH') ? getenv('VUFIND_APPLICATION_PATH')
+            : dirname(__DIR__))
+    );
 
 // Define application environment
 defined('APPLICATION_ENV')
-    || define('APPLICATION_ENV', (getenv('VUFIND_ENV') ? getenv('VUFIND_ENV') : 'production'));
+    || define(
+        'APPLICATION_ENV',
+        (getenv('VUFIND_ENV') ? getenv('VUFIND_ENV') : 'production')
+    );
 
 // Define path to local override directory
 defined('LOCAL_OVERRIDE_DIR')
-    || define('LOCAL_OVERRIDE_DIR', (getenv('VUFIND_LOCAL_DIR') ? getenv('VUFIND_LOCAL_DIR') : ''));
+    || define(
+        'LOCAL_OVERRIDE_DIR',
+        (getenv('VUFIND_LOCAL_DIR') ? getenv('VUFIND_LOCAL_DIR') : '')
+    );
 
 // Save original working directory in case we need to remember our context, then
 // switch to the application directory for convenience: