사이트 접두어 변경

다음 샘플 컨트롤러 파일은 사이트를 여러 접두어로 제공할 수 있도록 preInitRendering 함수를 정의합니다.

주:

이 샘플을 사용하려면 정의된 접두어에 응답하도록 CDN 또는 다른 프록시가 구성되어 있어야 합니다. 또한 함수에 정의된 추가 접두어가 브라우저 URL과 일치하지 않으면 기본 동작이 사용됩니다.
<!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>