Bucket redirection rules not working with folders

0

I have several pages in an S3 bucket with redirects like this:

http://domain.com/implementation -> http://domain.com/implementing-test http://domain.com/implementation/studies -> http://domain.com/implementing-test http://domain.com/implementation/purchasing -> http://domain.com/implementing-test http://domain.com/implementation/training -> http://domain.com/implementing-test http://domain.com/implementation/testing -> http://domain.com/implementing-test

So as you can see I want all traffic to the /implementation page and its sub pages to go to the new implementing-test page. The problem I'm having is the words after the second slash are being retained, so http://domain.com/implementation/studies actually redirects to http://domain.com/implementing-test/studies which doesn't exist.

I've tried a couple different variations in the JSON with no luck. Here's where I am now which is causing the above problem. { "Condition": { "KeyPrefixEquals": "implementation/studies" }, "Redirect": { "ReplaceKeyPrefixWith": "implementing-test" } }

After seeing an answer on Reddit I tried this, but got the same results. { "Condition": { "KeyPrefixEquals": "/implementation" }, "Redirect": { "ReplaceKeyPrefixWith": "implementing-test" } }

Someone else suggested using ReplaceKeyWith instead of ReplaceKeyPrefixWith but that also yielded the same result.

Any suggestions?

질문됨 2년 전802회 조회
1개 답변
0

Hello

I have created a test environment with the information reported, Here is the info that i have done.

  • I have created index.html and two folders abc/, cde and abc/bcd
  • I have added the redirection rule example below
  • As you can see it is a loop for cde/ goes to abc again abc have the redirection to implementing-test-page/test-page.html, I am able to redirect with success

Observations:

  • Patience is required because after an update of the json file it is taking few min for the update
[
    {
        "Condition": {
            "KeyPrefixEquals": "abc/bcd/"
        },
        "Redirect": {
            "ReplaceKeyWith": "implementing-test-page/test-page.html"
        }
    },
    {
        "Condition": {
            "KeyPrefixEquals": "abc/"
        },
        "Redirect": {
            "ReplaceKeyWith": "implementing-test-page/test-page.html"
        }
    },
    {
        "Condition": {
            "KeyPrefixEquals": "cde/"
        },
        "Redirect": {
            "ReplaceKeyPrefixWith": "abc/"
        }
    }
]
profile picture
GK
답변함 2년 전

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

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

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

관련 콘텐츠