Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a domain with a .htaccess redirection problem. The active CDN the URL should be: but redirects: ->

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: CNAME


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.

share|improve this question
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 Jul 25 '14 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 to fetch the headers. –  jeffatrackaid Aug 28 '14 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 Aug 29 '14 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, 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 when it doesn't have a copy of the content. Log into your CDN account to make this setting change.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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