Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. No representations are made about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. Allows you to be discoverable on Mastodon with your own domain name, without needing to run your own server. Makes "you@your-domain" be an alias for "also-you@the-actual-mastodon-server". This is not as useful as it sounds. While it makes it possible for someone to search for "you@your-domain" and find you, it does not make your posts on Mastodon *present* themselves that way: they will still appear as "also-you@the-actual-mastodon-server". The only way to change that presentation is to run your whole own Mastodon instance, which takes a colossal amount of effort and resources. Created: 8-Nov-2022. Installation: - Edit $ACCOUNTS, below. - Install this script in "/.well-known/webfinger" - Make it be runnable, e.g. by putting this in "/.well-known/.htaccess" -- ForceType application/x-httpd-php */ $ACCOUNTS = [ // // Alias account name Real underlying account name // 'jwz@jwz.org' => 'jwz@mastodon.social', 'jwz@dnalounge.com' => 'jwz@mastodon.social', 'dnalounge@dnalounge.com' => 'dnalounge@sfba.social', 'dnapizza@dnapizza.com' => 'dnapizza@sfba.social', 'dnapizza@dnalounge.com' => 'dnapizza@sfba.social', ]; function webfinger() { global $ACCOUNTS; $acct = $_GET['resource'] ?? null; if (! $acct) error ("unparsable: no resource"); if (! preg_match ('/^(?:acct:)?@?(.*)$/s', $acct, $m)) error ("unparsable acct: \"$acct\""); $acct = $m[1]; $redir = $ACCOUNTS[strtolower($acct)] ?? null; if (!$redir) error ("no match: \"$acct\""); if (! preg_match ('/@(.*)$/s', $redir, $m)) error ("internal error: no domain"); $domain = $m[1]; $url = "https://$domain/.well-known/webfinger?resource=acct:$redir"; header ("HTTP/1.1 301 Moved Permanently"); header ("Location: $url"); header ("Content-Type: text/plain"); } function error($err) { $err = preg_replace ('/\s+/', ' ', $err); error_log ("webfinger: $err"); header ("HTTP/1.1 400 $err"); header ("Content-Type: text/plain"); print "$err\n"; exit (1); } webfinger(); exit (0);