-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert .htaccess files to use _headers
and _redirects
.
#855
base: 11ty
Are you sure you want to change the base?
Conversation
Deploying json-ld-org with
|
Latest commit: |
52b351d
|
Status: | ✅ Deploy successful! |
Preview URL: | https://5a9791b2.json-ld-org.pages.dev |
Branch Preview URL: | https://convert-htaccess-to-cf-files.json-ld-org.pages.dev |
113d763
to
772636c
Compare
This uses Cloudflare `wrangler` to serve the `_site/` folder with support for `_headers` and `_redirects` files.
@@ -0,0 +1,15 @@ | |||
/playground-dev /playground 302 | |||
|
|||
/contexts/schema.org.jsonld http://schema.org/ 301 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/contexts/schema.org.jsonld http://schema.org/ 301 | |
/contexts/schema.org.jsonld https://schema.org/ 301 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah...I was trying to avoid making any changes to the routing during this PR...but we probably should fix all the http://
destinations... I may do that in a final pass commit on this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that http://schema.org/ and https://schema.org are different, as all of the classes and properties get the scheme from the source file. Typically, and historically, we use the 'http' version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what we should be doing for ids in data. But in this case, their server will redirect to https anyway, so might as well avoid that extra step. It's possible the redirect here predates them supporting https and/or hosting a context file. I'm also not sure where this endpoint is used anymore
spec/ED/.htaccess
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird. Not sure why the SHA was different... Maybe a copy/paste fail. I'll update the commit message. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually looks like a stray b
wandered into the URL... Likely me VIMing faster than I should. It'll be fixed when I next push an update.
772636c
to
2f9629c
Compare
These redirects and headers are hard to check manually or visually. There should be a regression test so these don't break. If not now, should create an issue for it. |
Yeah, I went looking for some easy thing to do that testing with earlier...but everything requires hoisting up significant test framework mess. I may craft a small one-off JS file to do them instead. |
Cloudflare already supports the `.jsonld` extension properly (along with any/all other registered file exstensions). Cloudflare also turns CORS on by defualt for all origins.
The `images/README.md` was already handled, so the only addition to the ignores list is the `images/Makefile`.
This one never did what it intended to, judging by the commit it was added during: 5828deb
Some handled slashes, some did not. These should match what was previously in place.
CSS and images were not loading previously.
Sadly, Cloudflare currently only does content negotiation for images. However, the Pages Functions Middleware option is more than sufficient to handle the mapping and loading based on simple Accept header values. NOTE: the current implementation *is not* robust and only handles single value Accept headers.
This commit uses code generated by a Google AI Overview result. They cite no sources and claim no license. However, it is exactly what I was looking for with that search.
2f9629c
to
52b351d
Compare
@davidlehn I've not written a test script yet, but this should be ready in all other ways. |
This PR implements the
_headers
and_readirects
files used by Cloudflare (and many others) to handle simpleheader additions and redirects. These files are simpler formats than Apache HTTPD's
.htaccess
and canbe trivially used as documentation for other header and redirect formats (should the need arise).