Problem


I am in the process of transitioning from a Classic Microsoft CDN to a new CDN hosted under a different domain name. To ensure a seamless user experience during this migration, I intend to implement a redirection mechanism. This will automatically reroute users to the new CDN endpoint whenever they attempt to access resources from the old CDN. Let's see how to do it from Azure portal.

Solution


My old CDN is using domain name cdn-blog.edi.wang, when user access resources under this domain, the full URL will look like this:

https://cdn-blog.edi.wang/web-assets/mvp-logo.svg

I would like to make this request redirect to my new CDN cdn.edi.wang, which the URL should be:

https://cdn.edi.wang/web-assets/mvp-logo.svg

It's very simple.

1. Go to Rules engine blade in the old CDN endpoint.

2. Add a new rule:

  • Condition: Request URL
    • Operator: Any
  • Action: URL Redirect
    • Type: 301
    • Hostname: cdn.edi.wang

That's it. Now save changes and wait for a few minutes, the redirect rule is now effective.