WordPress.org

Ready to get started?Download WordPress

Forums

Super Cache rewrite rules causing endless loop ? (2 posts)

  1. RavanH
    Member
    Posted 6 years ago #

    Hi Donncha et al. ,

    Trying your excellent plugin (which does work fine so it seems) I noticed errors in the server errorlogfile like this one:

    [Fri Mar 14 15:33:08 2008] [error] [client 82.99.30.28] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.

    I am on a shared host and have no clue why, when or how these errors are caused. So I asked the server admin what could be causing these. He replied that it was probably caused by rewrite rules beginning with / and pointed me at http://www.sitepoint.com/print/mod_rewrite-no-endless-loops for more info.

    Now the date on that page is rather old, so it might not be valid anymore... Or does the server admin have a point here? Should the rules maybe be (notice the missing / at the two end rules):

    RewriteCond %{QUERY_STRING} !.*s=.*
    RewriteCond %{HTTP_COOKIE} !^.*comment_author_.*$
    RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$
    RewriteCond %{HTTP_COOKIE} !^.*wp-postpass_.*$
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
    RewriteRule ^(.*) wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]
    
    RewriteCond %{QUERY_STRING} !.*s=.*
    RewriteCond %{HTTP_COOKIE} !^.*comment_author_.*$
    RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$
    RewriteCond %{HTTP_COOKIE} !^.*wp-postpass_.*$
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
    RewriteRule ^(.*) wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]

    I have tested this on my WP_MU 1.3.3 and it seems to work fine... I have taken no long time to wait for new error lines in the logfile but at least the caching works.

    The WP_MU installation is in the httpdocs (root) so I have RewriteBase / in my .htaccess. No idea how these changes (if at all relevant) would impact installations in a subdir (I saw a thread about RewriteBase issues that may be related/affected?)...

    Can you, or anyone else, advise me on this matter?

    Thanks :)

  2. askapache
    Member
    Posted 6 years ago #

    This works for me,

    # BEGIN WordPress
    
    RewriteCond %{QUERY_STRING} !s
    RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.+)(/?)\ HTTP/ [NC]
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/%2/index.html.gz -f
    RewriteRule ^(.+)$ /wp-content/cache/supercache/%{HTTP_HOST}/%2/index.html.gz [L]
    
    RewriteCond %{QUERY_STRING} !s
    RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.+)(/?)\ HTTP/ [NC]
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/%2/index.html -f
    RewriteRule ^(.+)$ /wp-content/cache/supercache/%{HTTP_HOST}/%2/index.html [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    
    # END WordPress

Topic Closed

This topic has been closed to new replies.

About this Topic