Hi @JavedZi
Your rule: RewriteRule ^/content/my-project/([a-z]{2})/en/(.+)\.html$ /$1/$2 [R=301,L]
returns a relative redirect (/$1/$2).
Apache then builds the full Location header using the Host it sees on the request.
Right now, your CDN is calling the origin with something like: Host: publish.mycompany.com
So Apache/Dispatcher generates: Location: https://publish.mycompany.com/xx/yy
The CDN just passes that back to the browser > you see publish domain, not CDN domain.
This is exactly the "redirection to the publish service endpoint / wrong host" pattern described in the CDN docs. https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/content-delivery/cdn https://experienceleague.adobe.com/en/docs/experience-manager-learn/foundation/administration/url-redirection
1. Fix CDN > origin Host header
In your CDN config, make sure the Host header sent to AEM is the CDN domain (or at least the public site domain), not the internal publish host.
Most CDNs have a setting like:
- Preserve client Host header / Use incoming host / Override Host header = original request host – turn this on.
After this change, origin requests look like: Host: www.example.com # or your CDN domain
Now your existing rule: RewriteRule ^/content/my-project/([a-z]{2})/en/(.+)\.html$ /$1/$2 [R=301,L]
will produce: Location: https://www.example.com/xx/yy
so the browser stays on the CDN/public domain.
2. (Optional) If you want explicit absolute URLs
Only if you really need an absolute URL, keep it dynamic:
RewriteRule ^/content/my-project/([a-z]{2})/en/(.+)\.html$ https://%{HTTP_HOST}/$1/$2 [R=301,L]
This still depends on step 1: CDN must send the correct Host header, otherwise %{HTTP_HOST} will again be the publish domain.