Replies: 1 comment 1 reply
-
This is really interesting, thanks for all the detail. Once we figure it out, I'd like to put what you end up with working on the Statiq site if that's okay. I actually don't know anything about AWS hosting myself - I generally use a mix of GitHub Pages, Azure App Service, and Netlify. What I do know is that unlike GitHub Pages and Netlify, which are designed to support static sites, Azure App Service also requires some rewrite rules (at the bottom of https://statiq.dev/web/deployment/azure-app-service). As you've found, there are basically two separate conventions that need to be supported:
I wonder if there's some higher-level setting in AWS that turns on default index files for a site, before the rewrite rule even gets called? I.e. can you set
|
Beta Was this translation helpful? Give feedback.
-
This is an issue with a few potential solutions. I thought I'd ask here though, just in case anyone here has any ideas.
I am hosting two versions of my site:
https://dev.luzfaltex.com - GitHub Pages
https://www.luzfaltex.com - S3 + CloudFront
On the GitHub Pages version, the site works perfectly. This is also seen when using the
preview
command line argument. When using the AWS site any pages in subfolders are inaccessible (404).In order to replicate URL rewriting, I am using this lambda@edge script:
In my _MasterLayout.cshtml file, I have links being built like so:
When the navbar links are built, it looks like this (sample from index.html):
On pages like
projects.html
orabout.html
, the rewrite rule works perfectly. It sees that you're going to/projects
, the url does not end with a forward slash, and so it appends.html
. The url shows/projects
but you're actually being served/projects.html
.When going to the docs page on the other hand, it sees the same thing and attempts to server
/docs.html
, which is not a file that exists. The actual file it should serve here is/docs/index.html
.On the preview web server and on GitHub Pages, this is handled automatically and the correct page is served, even though it is the same HTML.
I see a few solutions to this:
/docs/
when it's going to an index file in a subdirectory.If anyone has any other ideas of how I may get around this issue and have the site behave as it does on GitHub Pages, I'm all ears.
(For bonus points, here are is the .htaccess rewrite rule I would be using)
Edit: I have attempted to rewrite the url rewrite script. This is the current version:
Beta Was this translation helpful? Give feedback.
All reactions