Fix For SSL Redirection Issue

This issue has been fixed as of 2.5.6. If you had previously implemented the fix below, you can remove the MU Plugin. 

You will just need to add the SSL redirection rules directly into your htaccess file according to these directions:  Redirect HTTP to https

Versions 2.5.5 and older

Sometimes if you run SSL on your website, there is a redirection issue where you'll see a url like this in your browser: 

https://example.com/wp-content/cache/wp-rocket/example.com/index.html_gzip

You can fix this issue by adding the following code in the functions.php file of your theme. After you add the snippet, deactivate and reactivate WP Rocket. 

add_filter( 'rocket_htaccess_marker', '__fix_wprocket_ssl_redirection' );
function __fix_wprocket_ssl_redirection( $marker ) {
	$redirection = '# Redirect http to https' . PHP_EOL;
	$redirection .= 'RewriteEngine On' . PHP_EOL;
	$redirection .= 'RewriteCond %{HTTPS} !on' . PHP_EOL;
	$redirection .= 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]' . PHP_EOL . PHP_EOL;
	$marker = $redirection . $marker;
	return $marker;
}


Alternatively, for better maintainability you can also fix this by creating a must-use (mu) plugin: 

1) Create a directory mu-plugins in wp-content 
2) Using a basic text editor make a new file and paste the following code. 

<?php 
defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' );
/*
Plugin Name: Fix SSL Redirection with WP Rocket
Author: Jonathan (WP Rocket Team)
Author URI: http://wp-rocket.me
*/
add_filter( 'rocket_htaccess_marker', '__fix_wprocket_ssl_redirection' );
function __fix_wprocket_ssl_redirection( $marker ) {
        $redirection = '# Redirect http to https' . PHP_EOL;
        $redirection .= 'RewriteEngine On' . PHP_EOL;
        $redirection .= 'RewriteCond %{HTTPS} !on' . PHP_EOL;
        $redirection .= 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]' . PHP_EOL . PHP_EOL;
        $marker = $redirection . $marker;
        return $marker;
}

3) Save the file as: wprocket-sslfix.php (actually you can name it anything you want, this is just a suggestion ) 
4) Upload this file to the mu-plugins folder 
5) Finally, make sure to deactivate / re-activate WP Rocket. 

Multisite Compatibility

If you are using a multisite installation, you have to replace this line:

$redirection .= 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]' . PHP_EOL . PHP_EOL;

by:

$redirection .= 'RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]' . PHP_EOL;
$redirection .= 'RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]' . PHP_EOL . PHP_EOL;

Make sure to replace “example.com” with the correct domain name for your site.

NGINX Compatibility

If you are using an NGINX server, use the following: 

server {
listen      80;
server_name example.com;
rewrite ^ https://$server_name$request_uri? permanent;
}
Make sure to replace “example.com” with the correct domain name for your site.