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
回答済み 1年前
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

回答済み 1年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ