Created
September 2, 2020 11:35
-
-
Save Burekasim/1c097c5bcd1297b1be09dd007f9ddaa3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lambda_handler(event, context): | |
host_header = event['Records'][0]['cf']['request']['headers']['host'][0]['value'] | |
new_host_header = host_header.replace('www.', '') | |
uri_path = event['Records'][0]['cf']['request']['uri'] | |
response = { | |
'status': '301', | |
'statusDescription': 'Found', | |
'headers': { | |
'location': [{ | |
'key': 'Location', | |
'value': 'https://' + new_host_header + uri_path | |
}] | |
} | |
} | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment