How to redirect or change all incoming urls with file extension(aspx) to html using S3 redirection rule or Cloudfront

0

Hi, i want to know if it's possible and how to redirect or change all incoming urls with file extension(aspx) to html using S3 redirection rule or Cloudfront. i tried to used keyprefix but it's not working. i also add "HttpErrorCodeReturnedEquals": "404" to the following json instruction but did not work [ { "Condition": { "KeyPrefixEquals": (wildcard for anything before).aspx" }, "Redirect": { "ReplaceKeyWith": "(wildcard for anything before).html" } } ] the website is in statict s3 bucket

2개 답변
0
수락된 답변

S3 redirect only can change prefix which is basically the folder name. The prefix does not contain the file name. So, the way you want to do this is not supported.

The only other option you really have is to upload a zero-byte file with the .aspx extension that you want redirected to html. You will have to do this for every .html page you have. With that you can change the System Metadata to perform a 301 redirect to any other object.

So, say you have a page named /products/myproducts.html you would upload a zero-byte file named /products/myproducts.aspx (Note: It really does not have to be zero byte any content will work) In the meta data key of x-amz-website-redirect-location you will place /products/myproducts.html

Here are the examples on how to do the various rewrite rules if you need additional information.

With CloudFront you might be able to rewrite using lambda edge, but I don't think that would be easy or cost effective.

If your front end is actually a single page application using something angular or react you can do client-side routing and do this in the browser.

profile picture
답변함 일 년 전
0

i will do the redirection on the client side that was one of the option i was thinking to use. thank for the answer

답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠