Please follow the below template, it will help us to help you!
If you are Experiencing issues with a Pi-hole install that has non-standard elements (e.g you are using nginx instead of lighttpd, or there is some other aspect of your install that is customised) - please use the Community Help category.
Expected Behaviour:
When adding a subdomain with wildcard, it should work no matter what, as the wildcard is extended to all possible name variations. However, in reality, it is not working.
Subdomain added with wildcard into whitelist: (.|^)analytics.google.com$
Actual Behaviour:
1) Added Google Analytics subdomain with wildcard to whitelist:
(.|^)analytics.google.com$
It is not allowing me to open the following URL:
2) Added Google Analytics subdomain directly (without wildcard) to whitelist:
analytics.google.com
Now it allows me to open this URL:
Please let me know if this is a Pihole bug or what?
I have not customised at all the Pihole, is installed fresh and with standard options.
Your debug log shows that the wildcard has been addded to the blacklist, not the whitelist. That is why it would not allow you to open the URL.
The non-wildcard domain has been added to the whitelist. That is why it then allowed you to open the URL, since whitelists have priority over blacklists.
You can easily fix this in Domains by finding the wildcard entry and using the drop-down to change it to Regex whitelist. Once that's done you can remove the exact entry if you want, since the wildcard entry already covers it.
Note that your error log shows database errors. Try running pihole -r and select Repair.