Mastodon usernames different from the domain used for installation

Hugo GameiroMastodon, SysAdmin

By default when you install Mastodon on a domain, or subdomain, that will determine how the username of users on that Mastodon server will be. Example, if you install Mastodon on a user on that server will be

This can be changed and you can install Mastodon on but have your username be or even but that requires a configuration change to the domain used for usernames.

For this example let’s assume you want to install Mastodon on and have your usernames to end in

First you need to have a valid TLS/SSL certificate on Meaning that the domain should be accessible via https.

Second you need to create a response URL template response to when a webfinger query is made on The easiest is to just make a redirect. Any query made to should redirect to and append to the URL any parameters passed.

So, if a query is made to:
it should redirect to:

Now if on you are using Nginx you can do something like:

location = /.well-known/host-meta {
return 301$request_uri;

If on you are using Apache you can do something like:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/.well-known/host-meta(.)$ RewriteRule ^(.) [R=302,NC]

I have reports of people using a static XML file that have also worked but I am not sure what problems this might cause. Something like this should respond on even when parameters exist in the URL:

<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="">
  <Link rel="lrdd" type="application/xrd+xml" template="{uri}"/>

Finally in the Mastodon configuration (.env.production) you should set LOCAL_DOMAIN and WEB_DOMAIN values. Using the previous example:

If you are hosting with me, then this final step about the Mastodon configuration is not necessary. You just need to reply to the email you got when you first sign up requesting that change during the installation process.