To enable ACME Challenge support on all HTTP virtual hosts and avoid errors due to configuration/rewrite on generation or renewing SSL certificates from Let’s Encrypt you must configure a location alias.
For Apache:
Alias /.well-known/acme-challenge/ /var/www/default/.well-known/acme-challenge/ <Directory "/var/www/default/.well-known/acme-challenge/"> Options None AllowOverride None ForceType text/plain RedirectMatch 404 "^(?!/\.well-known/acme-challenge/[\w-]{43}$)" </Directory>
For Nginx:
location "/.well-known/acme-challenge" { allow all; default_type "text/plain"; root /var/www/default; }