쿠키 기본 설정 선택

당사는 사이트와 서비스를 제공하는 데 필요한 필수 쿠키 및 유사한 도구를 사용합니다. 고객이 사이트를 어떻게 사용하는지 파악하고 개선할 수 있도록 성능 쿠키를 사용해 익명의 통계를 수집합니다. 필수 쿠키는 비활성화할 수 없지만 '사용자 지정' 또는 ‘거부’를 클릭하여 성능 쿠키를 거부할 수 있습니다.

사용자가 동의하는 경우 AWS와 승인된 제3자도 쿠키를 사용하여 유용한 사이트 기능을 제공하고, 사용자의 기본 설정을 기억하고, 관련 광고를 비롯한 관련 콘텐츠를 표시합니다. 필수가 아닌 모든 쿠키를 수락하거나 거부하려면 ‘수락’ 또는 ‘거부’를 클릭하세요. 더 자세한 내용을 선택하려면 ‘사용자 정의’를 클릭하세요.

최종 사용자를 새 URL로 리디렉션

포커스 모드
최종 사용자를 새 URL로 리디렉션 - Amazon CloudFront

다음 뷰어 요청 함수는 요청이 특정 국가 내에서 오는 경우 뷰어를 국가별 URL로 리디렉션하는 응답을 생성합니다. 이 함수는 CloudFront-Viewer-Country 헤더의 값에 의존하여 최종 사용자의 국가를 결정합니다.

중요

이 함수가 실행되려면 캐시 정책 또는 오리진 요청 정책의 허용되는 헤더 목록에 헤더를 추가하여 수신되는 요청에 CloudFront-Viewer-Country 헤더를 추가하도록 CloudFront를 구성해야 합니다.

이 예에서는 독일에 대한 최종 사용자 요청이 독일에서 오는 경우 최종 사용자를 독일에 고유한 URL로 리디렉션합니다. 최종 사용자 요청이 독일에서 오지 않는 경우 함수는 수정되지 않은 원래의 요청을 반환합니다.

GitHub에서 이 예제를 참조하세요.

JavaScript runtime 2.0
async function handler(event) { const request = event.request; const headers = request.headers; const host = request.headers.host.value; const country = Symbol.for('DE'); // Choose a country code const newurl = `https://${host}/de/index.html`; // Change the redirect URL to your choice if (headers['cloudfront-viewer-country']) { const countryCode = Symbol.for(headers['cloudfront-viewer-country'].value); if (countryCode === country) { const response = { statusCode: 302, statusDescription: 'Found', headers: { "location": { "value": newurl } } } return response; } } return request; }
JavaScript runtime 1.0
function handler(event) { var request = event.request; var headers = request.headers; var host = request.headers.host.value; var country = 'DE' // Choose a country code var newurl = `https://${host}/de/index.html` // Change the redirect URL to your choice if (headers['cloudfront-viewer-country']) { var countryCode = headers['cloudfront-viewer-country'].value; if (countryCode === country) { var response = { statusCode: 302, statusDescription: 'Found', headers: { "location": { "value": newurl } } } return response; } } return request; }
async function handler(event) { const request = event.request; const headers = request.headers; const host = request.headers.host.value; const country = Symbol.for('DE'); // Choose a country code const newurl = `https://${host}/de/index.html`; // Change the redirect URL to your choice if (headers['cloudfront-viewer-country']) { const countryCode = Symbol.for(headers['cloudfront-viewer-country'].value); if (countryCode === country) { const response = { statusCode: 302, statusDescription: 'Found', headers: { "location": { "value": newurl } } } return response; } } return request; }

재작성 및 리디렉션에 대한 자세한 내용은 AWS 워크샵 스튜디오에서 엣지 함수를 사용하여 재작성 및 리디렉션 처리하기를 참조합니다.

프라이버시사이트 이용 약관쿠키 기본 설정
© 2025, Amazon Web Services, Inc. 또는 계열사. All rights reserved.