Changing the Site Prefix

The following sample controller file defines a preInitRendering function to allow the site to be delivered on multiple prefixes.

Note:

To make use of this sample, a CDN or other proxy must be configured to respond to the defined prefixes. Also, if none of the additional prefixes defined in the function match the browser URL, the default behavior is used.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1">
<script type="text/javascript">
var SCS = { sitePrefix: '/SampleSite/' };
 
SCS.preInitRendering = function() {
     // List additional site prefixes here. All sitePrefix values MUST start and end with a '/' character.
     var additionalSitePrefixes = [
           '/corporate/intranet/SampleSite/',
           '/marketing/preflight/',
           '/qa/'
     ];
 
     // Determine if the actual browser URL matches one of the additional site prefixes
     var pageUrl = decodeURI(window.location.pathname);
     var i, prefix;
     for (i = 0; i < additionalSitePrefixes.length; i++) {
           prefix = additionalSitePrefixes[i];
           if (pageUrl.startsWith(prefix) || (pageUrl === prefix.slice(0, -1))) {
                // If we find a match, set the global site prefix variable
                SCS.sitePrefix = prefix;
                break;
           }
     }
};
</script>
<script src="/SampleSite/_sitesclouddelivery/renderer/controller.js"></script>
</head>
<body id="scsControllerBody"><noscript>This site requires JavaScript to be enabled.</noscript>
<img id="scsWaitImage" style="display: none; margin-top: 5%; margin-left: auto; margin-right: auto;" src="data:image/png;base64,..." />
</body></html>