Amazon web services 我需要使用cloudfront和s3重定向我的url
我有一个url,比如说Amazon web services 我需要使用cloudfront和s3重定向我的url,amazon-web-services,url,redirect,amazon-s3,amazon-cloudfront,Amazon Web Services,Url,Redirect,Amazon S3,Amazon Cloudfront,我有一个url,比如说example.com/eu/blog/,在这个页面中,我有一个按钮,当任何用户点击按钮时,它会转到oil-gas.com/en(这是一个不同的网站)。。现在我希望这个链接是example.com/eu/blog/oil-gas/en,目前我在example.com/eu/blog/oil-gas/en中没有任何内容 我已经使用了ApacheProxyPass,它可以正常工作,但我想知道我们是否可以使用S3、cloudfront实现这一点。。我们可以在S3中创建bucket
example.com/eu/blog/
,在这个页面中,我有一个按钮,当任何用户点击按钮时,它会转到oil-gas.com/en
(这是一个不同的网站)。。现在我希望这个链接是example.com/eu/blog/oil-gas/en
,目前我在example.com/eu/blog/oil-gas/en
中没有任何内容
我已经使用了ApacheProxyPass,它可以正常工作,但我想知道我们是否可以使用S3、cloudfront实现这一点。。我们可以在S3中创建bucket并启用带有重定向的静态主机吗。。。我希望url特别是
example.com/eu/blog/oil-gas/en
。请提供更多帮助或建议您可以通过添加函数在CloudFront中设置重定向。这将添加到源响应事件中
代码如下所示
def lambda_handler(event, context):
request = event["Records"][0]["cf"]["request"]
response = event["Records"][0]["cf"]["response"]
#If it matches this path perform a redirect
if request['uri'] == "url/to/redirect":
response = {
'status': '302',
'statusDescription': 'Found',
'headers': {
'location': [{
'key': 'Location',
'value': 'http://example.com/eu/blog/oil-gas/en'
}]
}
}
return response
以下是一些。您可以通过添加函数在CloudFront中设置重定向。这将添加到源响应事件中 代码如下所示
def lambda_handler(event, context):
request = event["Records"][0]["cf"]["request"]
response = event["Records"][0]["cf"]["response"]
#If it matches this path perform a redirect
if request['uri'] == "url/to/redirect":
response = {
'status': '302',
'statusDescription': 'Found',
'headers': {
'location': [{
'key': 'Location',
'value': 'http://example.com/eu/blog/oil-gas/en'
}]
}
}
return response
这里有一些