I have a domain with a .htaccess redirection problem. The active CDN the URL should be: cdn.domain.mx/images/test.png but redirects:

cdn.domain.mx/images/something.png -> www.domain.mx/images/something.png

This causes my web resources not to be served from the CDN. Here is the code in the .htaccess:

RewriteEngine on

RewriteCond %{HTTPS} on
RewriteRule (.*) http:\/\/%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTP_HOST} ^domain\.com$ [OR,NC]
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [OR,NC]
RewriteCond %{HTTP_HOST} ^domain\.example\.com$ [OR,NC]
RewriteCond %{HTTP_HOST} ^www\.domain\.example\.com$ [OR,NC]
RewriteCond %{HTTP_HOST} ^domain\.mx$ [NC]
RewriteRule ^(.*)$ http:\/\/www\.domain\.mx\/$1 [R=301,L]

I have also configured the CNAME on my domain:

cdn.domain.mx. CNAME domain.company.netdna-cdn.com


A resource site is:


The URL of the resource with CDN is:


If I enter the URL of the resource with CDN in my browser, I'm redirected to www. Redirection not indicated in the HTACCESS.

  • 1
    I am a bit confused by what your goal is. Your .htaccess code does not clarify it enough for me. Can you be clearer on what you are trying to do with the example .htaccess code? I suspect that you are not too far off.
    – closetnoc
    Commented Jul 25, 2014 at 22:50
  • Please provide real URLs. Unlike some forums, StackExchange sites encourage given actual details. Please update your post with a real link to the CDN URL and the direct URL. This way we can take a look at the headers. If you do not want to give the URLs, then you need to do this yourself. Use curl -I or redbot.org to fetch the headers. Commented Aug 28, 2014 at 15:31
  • @jeffatrackaid If I understand, in fact the actual urls here were published but John Conde user edited my post and deleted the original urls. What do I do in those cases?
    – Chofoteddy
    Commented Aug 29, 2014 at 16:22

1 Answer 1


CDN servers are configured to serve the resource if they already have a copy. If they don't have a copy, they need to fetch it from your website. To do so, they need to know what the address of your server is. You would have told them this information during the setup process for the CDN.

It seems likely to me that the CDN is set up to fetch content from domain.mx, www.domain.com or one of the other domains that you are redirecting. In that case, the CDN would serve redirects for those resources.

The solution would be to reconfigure your CDN to fetch content from www.domain.mx when it doesn't have a copy of the content. Log into your CDN account to make this setting change.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.