How to Use Custom Domain with CDN in Azure
- Go to Azure Portal
- Go to CDN and in Endpoints
- Click to add a Custom Domain and fill in the Custom Domain which is Hosted on GoDaddy etc.
- Now to avoid the Looping on website, After creating the CDN profile and endpoint, open it and go to Caching rules. Copy the following setup (highlighted the important bits, feel free to set the "cache expiration duration" to anything which fits you")
- Global caching rules - query string caching behavior - Cache every unique URL
- Custom caching Rules - Match Condition: Path - Match Value: /wp-admin/* - Caching behavior: Bypass cache
- Map your custom domain to your Azure CDN by adding the endpoint in CNAME WWW record
- For Naked Custom Domain , You need to double check if your TXT and A records on your DNS registrar using the configurations described
- A record to point to the IP address of your WebApp
- TXT record with host @ and value WebApp Url
The next step is map the requests to the CDN Custom Domain URL inside of your code by using Redirect Rules in .htaccess file..