I know you can't run PHP on Amazon S3, but is there a way to host a static site on S3 and then have a contact form that runs using PHP from another server? In essence, I'm asking if the PHP file needs to be on S3 for it to run properly?
1 Answer
No, the PHP file does not have to be on S3. Just put it on the other server and refer to the absolute (full) URL.
- Pages can submit forms to other domains (e.g. to the PHP server). This is actually what makes CSRF possible even when a server requires POST requests.
- Pages can load images, scripts, and stylesheets from other domains. In fact, it is very common for these assets to be loaded from separate servers or even third-party content delivery networks. For example, Stack Overflow loads its copy of jQuery from
//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js.