Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7278325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:51:33+00:00 2026-05-28T22:51:33+00:00

I am having a hard time figuring out what is wrong. As soon as

  • 0

I am having a hard time figuring out what is wrong.

As soon as I add my CDN’s code to my .htaccess to redirect static content to the CDN, it results in a redirect loop on those files.

I noticed they keep redirecting to themselves instead of loading the file.

My .htaccess:

RewriteEngine On

# Force no www
RewriteCond %{HTTP_HOST} ^www [NC]
RewriteRule ^.*$ http://domain.com/$0 [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://domain.com/ [R=301,L]

# Rewrite domain.com/p/contact to index.php?p=contact
RewriteRule ^p/([^/]+)/?$ /index.php?p=$1 [L]

My CDN’s code that breaks the site:

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault A0

    # Set up caching for 1 week(s)
    <FilesMatch "\.(jpe?g|gif|png|bmp|pdf|docx?|xlsx?|ppt|rar|zip|tar|gz|tgz|bz2|flv|avi|mov|wmv|mp3|wav)$">
        ExpiresDefault A604800
        Header append Cache-Control "public"
    </FilesMatch>

    # Set up caching for 1 day(s)
    <FilesMatch "\.(xml|txt)$">
        ExpiresDefault A86400
        Header append Cache-Control "public"
    </FilesMatch>

    # Set up caching for 1 hour(s)
    <FilesMatch "\.(js|css)$">
        ExpiresDefault A3600
        Header append Cache-Control "proxy-revalidate"
    </FilesMatch>

    # Force no caching for dynamic files
    <FilesMatch ".(php|cgi|pl|htm)$">
        ExpiresActive Off
        Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
        Header set Pragma "no-cache"
    </FilesMatch>
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP:Via}   !\.s\.worldcdn\.com
    # Flash wont work on cross-domain by default
    RewriteCond $1            !^.swf$ [NC]
    RewriteCond $1            "\.(jpe?g|gif|png|bmp|ico|js|css|pdf|docx?|xlsx?|ppt|rar|zip|tar|gz|tgz|bz2|flv|avi|mov|wmv|mp3|wav|xml|txt)$" [NC]
    RewriteRule ^(.*)           http://cdn.domain.com/$1 [L,R]
</IfModule>

Subdomains, CDN etc. are all set up correctly.

Maybe it’s a problem with the CDN?
Cheers for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T22:51:34+00:00Added an answer on May 28, 2026 at 10:51 pm

    From Flag L: Apache Docs: flag_l :

    If you are using RewriteRule in either .htaccess files or in <Directory> sections, it is important to have some understanding of how the rules are processed. The simplified form of this is that once the rules have been processed, the rewritten request is handed back to the URL parsing engine to do what it may with it. It is possible that as the rewritten request is handled, the .htaccess file or section may be encountered again, and thus the ruleset may be run again from the start. Most commonly this will happen if one of the rules causes a redirect – either internal or external – causing the request process to start over.


    Since, rewritten request is handed back to the URL parsing engine, after redirect from the last RewriteRule here,

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTP:Via}   !\.s\.worldcdn\.com
        # Flash wont work on cross-domain by default
        RewriteCond $1            !^.swf$ [NC]
        RewriteCond $1            "\.(jpe?g|gif|png|bmp|ico|js|css|pdf|docx?|xlsx?|ppt|rar|zip|tar|gz|tgz|bz2|flv|avi|mov|wmv|mp3|wav|xml|txt)$" [NC]
        RewriteRule ^(.*)           http://cdn.domain.com/$1 [L,R]
    </IfModule>
    

    either
    edit this line to :

        RewriteRule ^(.*)           http://cdn.domain.com/$1 [L]
    

    or,

    if you want to have the URI change at the browser as well, add the first RewriteCond

        RewriteCond %{HTTP_HOST}  !cdn\.domain\.com
        RewriteCond %{HTTP:Via}   !\.s\.worldcdn\.com
        RewriteCond $1            !^.swf$ [NC]
        RewriteCond $1            "\.(jpe?g|gif|png|bmp|ico|js|css|pdf|docx?|xlsx?|ppt|rar|zip|tar|gz|tgz|bz2|flv|avi|mov|wmv|mp3|wav|xml|txt)$" [NC]
        RewriteRule ^(.*)           http://cdn.domain.com/$1 [L,R]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some hard time figuring out what's wrong in this simple code: This
I'm having quite a hard time figuring out what's going wrong here: class iterate():
I'm having a hard time figuring out how i can add an arraylist into
I am having a hard time figuring out how to code a series of
I'm having a hard time figuring out what I'm doing wrong. I want do
Having a hard time figuring out the best way to do this... I have
I'm having a hard time figuring out how to architect the final piece of
I'm having a hard time figuring out how Firefox and Chrome determining what fields
I am having a hard time figuring out how to show an Image (or
I am having a hard time figuring out good reasons for the dependency property.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.