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?

gefragt vor 2 Jahren802 Aufrufe
1 Antwort
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
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen