W3 Total Cache and .htaccess

Hi,

I am trying to install the Total Cache plugin on a bitnami ami hosted on Amazon EC2. The problem is that I keep getting this error:

FTP credentials don’t allow to write to file /.htaccess

W3 Total Cache Error: Files and directories could not be automatically created to complete the installation.

It suggests me to add this to the .htaccess file:

# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
    <IfModule mod_headers.c>
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
        AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json
    <IfModule mod_mime.c>
        # DEFLATE by extension
        AddOutputFilter DEFLATE js css htm html xml
    </IfModule>
</IfModule>
# END W3TC Browser Cache

I have tried by creating different .htaccess files in different directories but still not working. I have tried also with the httpd.conf files.

If I try to update the content with the integrated FTP action, it doesn’t work either (FTP or SFTP). I have tried to update the password in the wp-config.php as suggested (by creating one via SSH first) but still doesn’t work. What am I missing?

Thanks

Hi,

For security and performance reasons, we disabled .htaccess by default for the Bitnami apps. http://wiki.bitnami.com/Components/Apache/htaccess_configuration

In this case you can create a new file in the “wordpress/conf” folder and include it in the configuration. Try to create a new file called “htaccess.conf” with the W3C configuration that you posted and add the following line at the end of the “/opt/bitnami/apps/wordpress/conf/http-app.conf” file:

Include "/opt/bitnami/apps/wordpress/conf/htaccess.conf"

Then restart Apache:

$ sudo /opt/bitnami/ctlscript.sh restart apache

I hope it helps.

Thanks for your reply! I have tried that but it still not working. It looks like it can’t read the pasted W3C configuration but I have created the .conf file and included it in the http-app.conf file as you suggested.

Hi,

Do you mean that the changes applied to the http-app.conf are not working or that the plugin reports that are not yet applied? If it is the former, the problem is that the plugin is probably checking if the configuration is applied by checking the contents of the .htaccess, regardless of if they are already working properly.

If your website is publicly available you could check if it is gzipped using the below page:

http://www.whatsmyip.org/http-compression-test/

Or using the Google Chrome “Developers Tool” console (right click in the page and select “Inspect Element”). To do that, navigate to the “Network” tab, refresh the page, click on the first element, and in the “Headers” subtab you should see something like (Content-Encoding:gzip):

Hi and thanks for your reply.

I don’t understand what is the connection between the compression and the plugin: are you suggesting that a website compressed with gzip doesn’t allow the plugin to see the directives I have inserted into the .conf file? If so, how can I fix that?

Thanks again!

Hi @piede ,

Caching plugins will often “gzip” the cache itself in order to serve it more quickly to users. jjbitrock is basically saying that if you see gzip there, then the plugin is serving the gzipped cache, and thus is functioning correctly.

He is also correct in that W3 cache will continue to say it can’t find the htaccess code, even if it is working (because it only knows to check the .htaccess in your root directory, not the htaccess.conf). Even though it can’t see it, caching should still work.

1 Like

So there is no way to install the plugin without errors? Isn’t it possible to set up a classic .htaccess file instead?

Thanks a lot

@piede

I believe if you go into the httpd-app.conf and change “AllowOverride None” to “AllowOverride All” you should be able to use the traditional .htaccess

Hi @piede,

I suggest you not to use AllowOverride All. With this option, you can use .htaccess but there could be security issues.
I recommend you to follow the htaccess configuration guide in our wiki
http://wiki.bitnami.com/Components/Apache/htaccess_configuration

Best regards,
Carlos

Due to the security plugins, other plugins lost their writing permission to .htaccess and other files. Even you could not see the image which was recently updated. The solution is simple.

  1. Check the directory permission level is 755 (in case WordPress installed in the directory).
  2. Now check the file permission for .htaccess which is necessary to be 644. Otherwise, you will encounter the error.

Source: DoubtSolver

Hi @luckybhumkar,

Thank you for taking your time to let us know. This will help the users that have the same issue.

Jota

You are welcome dear jota…Every feedback inspires…!

1 Like