Is it possible to use mod_rewrite on Amazon S3?

www.example.com/about.html -> mybucket.s3.amazon.com/index.html
www.example.com/welcome.html -> mybucket.s3.amazon.com/index.html
www.example.com/contact.html -> mybucket.s3.amazon.com/index.html


  • How come you haven't just got a CNAME pointing at your S3 bucket? Commented Feb 22, 2011 at 17:08
  • @PiersKarsenbarg Can you say more about what you were thinking here? A CNAME will bind a particular host to the bucket host -- how does this help with mod_rewrite config? The user isn't just asking to transfer requests from a.com/a to b.com/a; they want a.com/a -> b.com/p
    – duhaime
    Commented Feb 15, 2018 at 23:52

1 Answer 1


The examples you shared here don't require rewriterules on amazon s3 itself, the redirections all happen on the www.example.com site: so either in .htaccess or vhost conf or httpd.conf:

Options +FollowSymlinks
RewriteEngine On
RewriteRule ^/(about|welcome|contact)\.html$ http://mybucket.s3.amazon.com/index.html [R,L]

Granted, this will change the URL shown in the browser. If you want to do this without it being so apparent to the end user, then as @piers says, you will need to add a cname for your bucket on s3. and then reference/link to these files at your new http://mybucketalias.example.com/index.html address.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.