Skip to content

Instantly share code, notes, and snippets.

@matsuu matsuu/GDPR.md forked from zero-master/GDPR.md
Last active Sep 11, 2018

Embed
What would you like to do?
Show visitors from EU countries a page with GDPR message using Cloudflare and .htaccess

Turn on Cloudflare IP Geolocation

https://support.cloudflare.com/hc/en-us/articles/200168236-What-does-Cloudflare-IP-Geolocation-do-

In your .htaccess file:

RewriteEngine on
RewriteCond %{HTTP:CF-IPCountry} ^(AT|BE|BG|CY|CZ|DK|EE|FI|FR|DE|GR|HU|HR|IE|IT|LV|LT|LU|MT|NL|PL|PT|RO|SK|SI|ES|SE|GB)$
RewriteCond %{REQUEST_URI} !^/blockedGDPR/
RewriteRule ^ - [F,L]

ErrorDocument 403 /blockedGDPR/

Create a file named index.html in blockedGDPR directory with the below content:

<html>
  <title>
   GDPR Block
  </title>
  <body>
  We are unable to bear GDPR compliance cost at the moment.
  </body>
  <style>
    body {
      font-family: 'Avenir', Helvetica, Arial, sans-serif;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
      color: #2c3e50;
      margin-top: 20px;
    }
    </style>
    
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.