2

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

Thanks!

2
  • How come you haven't just got a CNAME pointing at your S3 bucket? Feb 22 '11 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
    Feb 15 '18 at 23:52
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, privacy policy and cookie policy