diff --git a/themes/bootstrap3/js/common.js b/themes/bootstrap3/js/common.js
index 40e107357412e6b95a2451b2752898c3c02f4c96..a0b93c1628f2de83ce9bf807e9bf08bec33dc6a2 100644
--- a/themes/bootstrap3/js/common.js
+++ b/themes/bootstrap3/js/common.js
@@ -163,10 +163,10 @@ function getUrlRoot(url) {
   var urlroot = null;
   var urlParts = url.split(/[?#]/);
   var urlWithoutFragment = urlParts[0];
-  if (VuFind.path === '') {
+  if (VuFind.path === '' || VuFind.path === '/') {
     // special case -- VuFind installed at site root:
     var chunks = urlWithoutFragment.split('/');
-    urlroot = '/' + chunks[3] + '/' + chunks[4];
+    urlroot = '/' + chunks[1] + '/' + chunks[2];
   } else {
     // standard case -- VuFind has its own path under site:
     var slashSlash = urlWithoutFragment.indexOf('//');