WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
Redirect Loop - htaccess conflict? (11 posts)

  1. tigertiger
    Member
    Posted 3 years ago #

    I'm using the latest versions of WP and W3TC.

    I have rewrite rules in my .htaccess to make "tigercooke.com" become "www.tigercooke.com".

    I've recently installed W3TC. The site is now working, but is still slow. I suspect the problem is this :

    /wp-content/w3tc-tigercooke.com/min/9349ce/default.include.1368345474.css
    is being rewritten as :
    /wp-content/w3tc-tigercooke.com/min/9349ce/www.tigercooke.com

    The problem replicates for a few other cached .js files too. The website loads eventually, but it's not fast.

    Has anyone come across this conflict before?
    Or could anyone suggest a solution, either on a more specific .htaccess rule to avoid trying to rewrite the "w3tc-tigercooke.com", or maybe a way to rename the "w3tc-tigercooke.com" folder name within the plugin?

    Any help would be greatly appreciated!

  2. efikim
    Member
    Posted 3 years ago #

    what .htaccess rule are you currently using?

  3. tigertiger
    Member
    Posted 3 years ago #

    These are the ones I'm currently using :

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]

    # to redirect tigercooke.com to http://www.tigercooke.com
    RewriteCond %{HTTP_HOST} ^tigercooke\.com$ [NC]
    RewriteRule ^(.*)$ http://www.tigercooke.com/$1 [R,L]

    # to redirect tadhgcooke.com to http://www.tigercooke.com
    RewriteCond %{HTTP_HOST} ^tadhgcooke\.com$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www\.tadhgcooke\.com$ [NC]
    RewriteRule ^(.*)$ http://www.tigercooke.com/$1 [R,L]

    There are also some rules left over from WP Super Cache which I don't understand yet :

    # uploaded files
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule . /index.php [L]

  4. efikim
    Member
    Posted 3 years ago #

    Your redirect of tigercooke to http://www.tigercooke is fine - it won't do a redirect of xxx.tigercooke

    Its almost the same as the one I changed my redirect to to avoid problems with an additional redirect:

    #
    RewriteCond %{HTTP_HOST} ^roguegenecollective.com$ [NC]
    RewriteRule ^(.*)$ http://www.roguegenecollective.com/$1 [L,R=301]
    #

    Strictly speaking, yours is more correct, as the '.' in mine rather than '\.' in yours matches any character. I have R=301 rather than just R as I can never remember which redirect is the default (301 is 'permanent', I hope!)

    I don't know what the extra rules you have are doing, sorry!

  5. tigertiger
    Member
    Posted 3 years ago #

    Thanks efikim.

    I think my problem is related to this, rather than the domain rewrite :
    /wp-content/w3tc-tigercooke.com/

    All I want to do is rewrite the domain, but I think when htaccess sees the /w3tc-tigercooke.com within the url it treats that in the same way as a domain, so I end up with http://www.tigercooke.com appended to the entire url.

    I've experimented with a few rules using the ! operator and trying to get an IF/ELSE thing going, but I seem to be either generating server errors, creating loops or just not making any change whatsoever. Arg.

  6. efikim
    Member
    Posted 3 years ago #

    The RewriteCond rule you have is very specific:

    firstly the %{HTTP_HOST} means just look at the domain name
    then the ^ means 'starts with' and the $ means 'end of string' and you've specified exactly every character in between.
    so it should only fire for a url beginning with the domain name http://tigercooke.com/ (NC just means ignore case)
    (it shouldn't look for any matches after the domain name - if it does, something else is broken!)

    Then the RewriteRule just says take everything that came after the domain name and stick it unchanged after the new domain name 'http://www.tigercooke.com/'.

    This rule shouldn't be looking beyond the domain name, so shouldn't be the cause of what you're seeing.

    PS - for short term testing to check this, you could just comment out that rule for a quick test.

  7. tigertiger
    Member
    Posted 3 years ago #

    Hmmm. That's a puzzler then.

    Is it possible that W3TC is causing the loop error then?

  8. efikim
    Member
    Posted 3 years ago #

    I don't know, sorry.
    needs input from Frederick I think!

  9. tigertiger
    Member
    Posted 3 years ago #

    Okay... I've narrowed it down a little. When I look at the source code generated for the website, this code appears in the head :

    http://css.tigercooke.com/wp-content/w3tc-tigercooke.com/min/9349ce/default.include.1368345474.css

    But there's no such file in that location. There IS a "default.include.css.id" file which contains just the number : 1368345474

    Then it's rewritten as :

    http://css.tigercooke.com/wp-content/w3tc-tigercooke.com/min/9349ce/www.tigercooke.com

    There is a .htaccess file in the "min" folder with rewrite rules in it. Could that be a source of the problem?

    (There's a similar error for the minified js file, but I figure if I sort the CSS problem out, it'll fix the JS problem too.)

  10. tigertiger
    Member
    Posted 3 years ago #

    By (lengthy) process of elimination it's just the minify module that's causing problems for me. I can't seem to debug it. If anyone knows of a solution to this, please let me know. Thanks!

    Everything else seems to be working fine - although the far-future expires still isn't setting correctly for some files.

  11. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    The .htaccess file in the w3tc/min/ directory isn't working on your server. Minify working has nothing to do with the response time from your server being high. If you paste the your entire .htaccess file here or better yet fill out a bug submission form from the support tab of the plugin.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic