Forums

[Plugin: WP Super Cache] Need help amending the htaccess file to make this work! (5 posts)

  1. WendyWeb
    Member
    Posted 2 years ago #

    After activating the plugin and adding the code snippet to my configuration file, I get the following message, even though my htaccess was temporarily made writable for the installation. (I believe that when installing on another site, htaccess was automatically updated for me.. I"m not certain why it is not doing that now).

    You must have BEGIN and END markers in /usr/www/users/usmissio/news/.htaccess for the auto update to work. They look like this and surround the main WordPress mod_rewrite rules: # BEGIN WordPress RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress

    My current htaccess file looks like this.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /news/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /news/index.php [L]
    </IfModule>

    It is unclear to me what parts of the first begin and end code I should insert and where I should put it. What part goes ahead of my code and what comes at the end (if it is a wrapper)? These instructions are not clear to someone like myself who is not all that comfortable with the code.

  2. Pranav Rastogi
    Member
    Posted 2 years ago #

    If it's not doing it, just do it manually. Put the WP Super Cache rules before this code:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /news/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /news/index.php [L]
    </IfModule>

    And upload the updated version of your .htaccess to the server.

  3. WendyWeb
    Member
    Posted 2 years ago #

    Thank you ulgaming. Do you mean that it should look like this?

    # BEGIN WordPress RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /news/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /news/index.php [L]
    </IfModule>

    Because the instructions indicate that the code should "surround" the existing code. That is what confused me. I thought perhaps part of the SuperCache code when in front of the existing code, and part came at the end...

  4. Pranav Rastogi
    Member
    Posted 2 years ago #

    No, this is the WordPress .htaccess code:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /news/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /news/index.php [L]
    </IfModule>

    You only have to add the mod_rewrite rules before that :

    # BEGIN WPSuperCache
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    AddDefaultCharset UTF-8
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|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 %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|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]
    </IfModule>
    # END WPSuperCache

    You will have different mod_rewrite rules, view them and add it to .htaccess .

    Rules must be added to /home/****/public_html/wp-content/cache/.htaccess too, this file would either be empty, or not be there or it will be there with the following data. If the data is not there, you just add it.

    # BEGIN supercache
    <IfModule mod_mime.c>
      AddEncoding gzip .gz
      AddType text/html .gz
    </IfModule>
    <IfModule mod_deflate.c>
      SetEnvIfNoCase Request_URI \.gz$ no-gzip
    </IfModule>
    <IfModule mod_headers.c>
      Header set Cache-Control 'max-age=300, must-revalidate'
    </IfModule>
    <IfModule mod_expires.c>
      ExpiresActive On
      ExpiresByType text/html A300
    </IfModule>
  5. WendyWeb
    Member
    Posted 2 years ago #

    Thanks Ulgaming, I'll try this and get back to you. Can't do it for a few days... to busy! But will definitely report here when it is done. Really appreciate you taking the time to respond!

Topic Closed

This topic has been closed to new replies.

About this Topic