0

I have a static website on aws S3 with CloudFront in front of it. The base url is served but all links display without .html and return "Access Denied". If I manually add .html to the link's url, the page is displayed.

I added some lines in my .htaccess files as suggested in this question but it didn't help. htaccess noww looks like this:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+?)/?$ /$1.html [L,R=302]

I tried some of the other suggestions with no luck. Is it possible that the problem is not in .htaccess file? Are there options in S3 or CloudFront?

EDIT: My question is about S3 + CloudFront which is different from S3 only. Just because the answer turns out to be the same, it doesn't mean the questions are the same.

Community
  • 1
  • 1
ERIK_SON
  • 379
  • 5
  • 16
  • S3 does not support the use of `.htaccess` files, so that would be why this doesn't work. CloudFront relies on the origin server to understand `.htaccess` files, and in this case the origin is S3, so, again, the contents of these files have no real purpose. Standard behavior in S3 is to return 403 instead of 404 when a file doesn't exist, because an anonymous user does not have permission to know *whether* the file exists and reading it is denied... or doesn't exist at all. – Michael - sqlbot Sep 08 '16 at 12:01
  • @Michael-sqlbot you are absolutely right. After several hours of reading and searching I realized the problem can not be solved using S3 and CF only. Now I'm wondering if I should delete that question, or let it stay for others to find and save time. – ERIK_SON Sep 08 '16 at 12:11
  • Possible duplicate of [Amazon S3 and .htaccess](http://stackoverflow.com/questions/14095818/amazon-s3-and-htaccess) – Michael - sqlbot Sep 08 '16 at 12:18

0 Answers0