diff --git a/dnsapi/dns_aws.sh b/dnsapi/dns_aws.sh
index 376936f5..5f922eac 100755
--- a/dnsapi/dns_aws.sh
+++ b/dnsapi/dns_aws.sh
@@ -178,7 +178,20 @@ _get_root() {
return 1
fi
- if _contains "$response" "$h."; then
+ if _contains "$response" "_acme-challenge.$h."; then
+ hostedzone="$(echo "$response" | sed 's//#&/g' | tr '#' '\n' | _egrep_o "[^<]*<.Id>_acme-challenge.$h.<.Name>.*false<.PrivateZone>.*<.HostedZone>")"
+ _debug hostedzone "$hostedzone"
+ if [ "$hostedzone" ]; then
+ _domain_id=$(printf "%s\n" "$hostedzone" | _egrep_o ".*<.Id>" | head -n 1 | _egrep_o ">.*<" | tr -d "<>")
+ if [ "$_domain_id" ]; then
+ _sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
+ _domain=_acme-challenge.$h
+ return 0
+ fi
+ _err "Can't find domain with id: _acme-challenge.$h"
+ return 1
+ fi
+ elif _contains "$response" "$h."; then
hostedzone="$(echo "$response" | sed 's//#&/g' | tr '#' '\n' | _egrep_o "[^<]*<.Id>$h.<.Name>.*false<.PrivateZone>.*<.HostedZone>")"
_debug hostedzone "$hostedzone"
if [ "$hostedzone" ]; then