7

I have a webapp hosted in Amazon S3, the webapp is build with jQuery Mobile and I use changePage lo navigate between pages, I'm not using the hash operator(#) when I change the page.

I'm having problems when the user copy the url and paste it in a new tab

For example:

http://www.exampleurl.com/page1.html

loads the page page1.html that is in amazon s3 with only the jquery page structure...

The behavior that I want is that load index.html and with js read the url, detect the page and load the correct page.

With Apache I solve this with URL Rewriting... but for Amazon S3 I didn't find any similar...

NOTE: I know that if I activate the hash operator (#) in my urls the problem is solved but I need clean urls without #.

Fernando P. G.
  • 141
  • 1
  • 1
  • 7
  • Amazon S3 is not a web server. It is an object storage system that happens to have an HTTP API. Yes, you can serve files from S3 to web browsers, but due to the fact that it is not a web server, it lacks this feature and many others that would typically be handled by apache/nginx/etc. – EEAA Dec 11 '14 at 00:01
  • Thank you EEAA! I know that is not a web server, but I thought maybe there was some way to do it because Amazon S3 has some (web server) features as for example custom redirection rules... – Fernando P. G. Dec 11 '14 at 14:25

1 Answers1

6

Finally I found a solution to my problem in this other question:

https://stackoverflow.com/questions/16267339/s3-static-website-hosting-route-all-paths-to-index-html

The goal is use this config in the Redirection Rules:

<RoutingRules>
  <RoutingRule>
    <Condition>
    <HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals >
     </Condition>
    <Redirect>
      <HostName>yourdomainname.com</HostName>
      <ReplaceKeyPrefixWith>#!/</ReplaceKeyPrefixWith>
    </Redirect>
  </RoutingRule>
</RoutingRules>
Fernando P. G.
  • 141
  • 1
  • 1
  • 7