title: Amazon s3 redirect rule with dynamic path value
body: <p>I have a S3 bucket and I am writing static web site hosting rules.
  My s3 is configured like this:</p>
  
  <pre><code>bucket
  ㄴ test
    ㄴ dynamic-value
      ㄴ us
        ㄴ en
          ㄴ index.html
      ㄴ default
        ㄴ index.html
  </code></pre>
  
  <p>this is my url:
  <a href="http://www.example.com/test/dynamic-value/us/en/index.html" rel="nofollow noreferrer">http://www.example.com/test/dynamic-value/us/en/index.html</a></p>
  
  <p>the "dynamic-value" is dynamic like A, B...</p>
  
  <p>And I want to redirect when response is 404:
  <a href="http://www.example.com/test/dynamic-value/default/index.html" rel="nofollow noreferrer">http://www.example.com/test/dynamic-value/default/index.html</a></p>
  
  <p>I want to change /us/en to /default my path, and the root path is dynamic when the page is 404 error.</p>
  
  <p>Before:</p>
  
  <pre><code>http://www.example.com/test/A/us/en/index.html
  http://www.example.com/test/B/us/en/index.html
  </code></pre>
  
  <p>After: </p>
  
  <pre><code>http://www.example.com/test/A/default/index.html
  http://www.example.com/test/B/default/index.html
  </code></pre>
  
  <p>I tried next rule, but it is not working. 
  the relative path(means "../../" in my code) works just "../../"(string).</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;RoutingRules&gt;
    &lt;RoutingRule&gt;
      &lt;Condition&gt;
        &lt;HttpErrorCodeReturnedEquals&gt;404&lt;/HttpErrorCodeReturnedEquals&gt;
      &lt;/Condition&gt;
      &lt;Redirect&gt;
        &lt;HostName&gt;www.example.com&lt;/HostName&gt;
        &lt;ReplaceKeyWith&gt;../../default/index.html&lt;/ReplaceKeyWith&gt;
      &lt;/Redirect&gt;
    &lt;/RoutingRule&gt;
  &lt;/RoutingRules&gt;
  </code></pre>
  
  <p>please help!!! :'(</p>