Italy Cookies Choices Fix

by admin

You need to do the following steps to use Italy Cookies Choices properly.

1. You need to add the following rule into htaccess

RewriteCond %{HTTP_COOKIE} displayCookieConsent [NC]
# BEGIN WpFastestCache

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.berkatan.com [NC]
RewriteRule ^(.*)$ http\:\/\/berkatan\.com\/$1 [R=301,L]
RewriteCond %{HTTP_USER_AGENT} !(facebookexternalhit)
################# HERE #################
RewriteCond %{HTTP_COOKIE} displayCookieConsent [NC]
################# HERE #################
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !(\/){2}$
RewriteCond %{QUERY_STRING} !.+
RewriteCond %{HTTP:Cookie} !(comment_author_|wordpress_logged_in|wp_woocommerce_session)
RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP_USER_AGENT} !^.*(iphone|midp|sony|symbos|nokia|samsung|mobile|epoc|ericsson|panasonic|philips|sanyo|sharp|sie-|portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc|android|blackberry|playbook|ipad|ipod|iemobile|palmos|webos|googlebot-mobile|bb10|xoom|p160u|nexus|touch|SCH-I800|opera\smini|SM-G900R4|LG-|HTC|GT-I9505|WAP-Browser|Nokia309|Casper_VIA).*$ [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/all/$1/index.html -f [or]
RewriteCond /home/username/public_html/wp-content/cache/all/$1/index.html -f
RewriteRule ^(.*) "/wp-content/cache/all/$1/index.html" [L]


AddDefaultCharset UTF-8

FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Mon, 29 Oct 1923 20:30:00 GMT"


# END WpFastestCache

2. To add the following php into /wp-fastest-cache/inc/cache.php 100. line

if ( !isset( $_COOKIE['displayCookieConsent'] ) ){
    return;
}
public function createCache(){		
	if(isset($this->options->wpFastestCacheStatus)){

		if(isset($this->options->wpFastestCacheLoggedInUser) && $this->options->wpFastestCacheLoggedInUser == "on"){
			// to check logged-in user
			foreach ((array)$_COOKIE as $cookie_key => $cookie_value){
				if(preg_match("/comment_author_|wordpress_logged_in|wp_woocommerce_session/i", $cookie_key)){
					return 0;
				}
			}
		}
        // ################# HERE #################
		if ( !isset( $_COOKIE['displayCookieConsent'] ) ){
			return;
		}
        // ################# HERE #################

		if(preg_match("/\?/", $_SERVER["REQUEST_URI"]) && !preg_match("/\/\?fdx\_switcher\=true/", $_SERVER["REQUEST_URI"])){ // for WP Mobile Edition
			return 0;
		}

		if(preg_match("/(".$this->get_excluded_useragent().")/", $_SERVER['HTTP_USER_AGENT'])){
			return 0;
		}

Related articles

Placeholder Image
Image Slider and Render-blocking JavaScript

Google recommends to load the JavaScripts after html, css and images.

Placeholder Image
Clearing Cache After Deleting Post/Page

When a post or a page is deleted, some cache files are cleared instead of all the cache files being…

Placeholder Image
Cloudflare Hotlink Protection

If the hotlink protection of Cloudflare has been enabled, the image optimization feature does not work. In this case, you…

Ready to get started?

Purchase your first license and see why 1,500,000+ websites globally around the world trust us.