Support » Fixing WordPress » Please help with my .htaccess file

  • I’m trying to block spam referrers like ranksonic and the plugin approach doesn’t seem to be working. I found that I can do this via the .htaccess file, but am not sure I’m doing it right. Here is the content of my file, it’s the lines at the bottom that are the issue. Can anyone please verify if I’m doing it right or not, and if I’m not, how can I fix it? Thanks!

    # ----------------------------------------------------------------------
    # CORS-enabled images (@crossorigin)
    # ----------------------------------------------------------------------
    # Send CORS headers if browsers request them; enabled by default for images.
    # developer.mozilla.org/en/CORS_Enabled_Image
    # blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html
    # hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/
    # wiki.mozilla.org/Security/Reviews/crossoriginAttribute
    <IfModule mod_setenvif.c>
      <IfModule mod_headers.c>
        # mod_headers, y u no match by Content-Type?!
        <FilesMatch "\.(gif|png|jpe?g|svg|svgz|ico|webp)$">
          SetEnvIf Origin ":" IS_CORS
          Header set Access-Control-Allow-Origin "*" env=IS_CORS
        </FilesMatch>
      </IfModule>
    </IfModule>
    # ----------------------------------------------------------------------
    # Webfont access
    # ----------------------------------------------------------------------
    # Allow access from all domains for webfonts.
    # Alternatively you could only whitelist your
    # subdomains like "subdomain.example.com".
    <IfModule mod_headers.c>
      <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$">
        Header set Access-Control-Allow-Origin "*"
      </FilesMatch>
    </IfModule>
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    RewriteCond %{REQUEST_METHOD} POST
    RewriteCond %{REQUEST_URI} .(wp-comments-post|wp-login)\.php*
    RewriteCond %{HTTP_REFERER} !.*(aftercredits.com|jetpack.wordpress.com).* [OR]
    RewriteCond %{HTTP_USER_AGENT} ^$
    RewriteRule (.*) http://%{REMOTE_ADDR}/$ [R=301,L]
    
    ## SITE REFERRER BANNING
    RewriteCond %{HTTP_REFERER} ranksonic.net [NC,OR]
    RewriteCond %{HTTP_REFERER} ranksonic.net
    RewriteCond %{HTTP_REFERER} traffic2cash.org [NC,OR]
    RewriteCond %{HTTP_REFERER} traffic2cash.org
    RewriteRule .* - [F]
    </IfModule>
    
    # END WordPress
Viewing 1 replies (of 1 total)
  • If you are going to play with your htaccess file, a little education might be helpful. you might want to look ath the book .htaccess made easy

    (I am in no way connected to the site or author except I own the book myself)

Viewing 1 replies (of 1 total)
  • The topic ‘Please help with my .htaccess file’ is closed to new replies.