Skip to content

AlahmadiQ8/S3-Routing-Rules-Builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Amazon S3 Routing Rules Builder

Inspired by Netlify's redirect syntax, build S3 conditional routing rules using a simple space separated syntax.

Usage

Visit the project Demo site and paste your redirect rules in the text editor. Here is an example below:

/home              /
/blog/my-post.php  /blog/my-post  301
/news              /blog          200
/google            https://www.google.com

This will be transformed into the following:

<RoutingRules>
    <RoutingRule>
        <Condition>
            <KeyPrefixEquals>/home</KeyPrefixEquals>
        </Condition>
        <Redirect>
            <ReplaceKeyPrefixWith>/</ReplaceKeyPrefixWith>
        </Redirect>
    </RoutingRule>
    <RoutingRule>
        <Condition>
            <KeyPrefixEquals>/blog/my-post.php</KeyPrefixEquals>
        </Condition>
        <Redirect>
            <ReplaceKeyWith>/blog/my-post</ReplaceKeyWith>
            <HttpRedirectCode>301</HttpRedirectCode>
        </Redirect>
    </RoutingRule>
    <RoutingRule>
        <Condition>
            <KeyPrefixEquals>/news</KeyPrefixEquals>
        </Condition>
        <Redirect>
            <ReplaceKeyWith>/blog</ReplaceKeyWith>
            <HttpRedirectCode>200</HttpRedirectCode>
        </Redirect>
    </RoutingRule>
    <RoutingRule>
        <Condition>
            <KeyPrefixEquals>/google</KeyPrefixEquals>
        </Condition>
        <Redirect>
            <Protocol>https</Protocol>
            <HostName>www.google.com</HostName>
        </Redirect>
    </RoutingRule>
</RoutingRules>

Built With