Chris W.
Chris W.

Reputation: 39219

How to use Amazon S3 to do domain forwarding while preserving URL paths?

My goal is to redirect a naked domain [example.org][1] to [www.example.org][2] while preserving the URL paths exactly.

e.g., a GET request to http://example.org/foobar/file.html results in a 302 to http://www.example.org/foobar/file.html

I do not want to setup or configure any servers to do this.

Currently the plan is to use Amazon's S3 static hosting redirect service (as suggested in this answer).

However, I cannot figure out how (or if its possible?) to configure the Amazon S3 bucket to perform the redirect while preserving the path.

Upvotes: 0

Views: 95

Answers (1)

Michael - sqlbot
Michael - sqlbot

Reputation: 179084

There are two options on the Static Website Hosting configuration screen, "Use this bucket to host a web site" and "Redirect requests."

Choose "Redirect requests." You're prompted only for the target hostname and port. This option automatically preserves the path.

The documentation doesn't seem to mention that fact, but that's what happens when you choose that option. You only need the more complicated routing rules if you want to modify the path, or only redirect certain paths.

Upvotes: 1

Related Questions