Last active
April 6, 2025 02:26
-
-
Save aaronpk/5846789 to your computer and use it in GitHub Desktop.
Added WebFinger support to my email address using one rewrite rule and one static file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[aaron@parecki.com www]$ cat .htaccess | |
RewriteEngine on | |
RewriteCond %{QUERY_STRING} resource=acct:(.+) | |
RewriteRule ^\.well-known/webfinger /profile/%1? [L] | |
[aaron@parecki.com www]$ cat profile/aaron@parecki.com | |
{ | |
"subject": "acct:aaron@parecki.com", | |
"links": [ | |
{ | |
"rel": "http://webfinger.net/rel/avatar", | |
"href": "http://aaronparecki.com/images/aaronpk.png" | |
}, | |
{ | |
"rel": "http://webfinger.net/rel/profile-page", | |
"href": "http://aaronparecki.com/" | |
}, | |
{ | |
"rel": "me", | |
"href": "http://aaronparecki.com/" | |
} | |
] | |
} | |
Alas according to the documentation RewriteMap
cannot be declared in a per-directory context including .htaccess
. So one probably need to name their json files with %40
instead of @
or symlink them because some clients (e.g. Mastodon) send unescaped requests. This also requires to support both :
and %3a
RewriteCond %{QUERY_STRING} resource=acct(:|%3[Aa])([^&]+)
RewriteRule ^\.well-known/webfinger /webfinger/%2? [NE,T=application/jrd+json;charset=UTF-8]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@sorenpeter asked:
No, the
RewriteCond
andRewriteRule
tells Apache, "when somebody asks for/.well-known/webfinger?resource=acct:SOMETHING
, instead serve them/profile/SOMETHING
". This then allows you to store static files in/profile/...
for each user account represented by webfinger and it pretty-much "just works".If the rules are working properly, you'll never need an actual file at
/.well-known/webfinger
.