我的谷歌分析中有很多推荐垃圾邮件,就像很多人一样 . 由于此垃圾邮件来自具有.to,.ru或.xyz等特定扩展名的域,因此我想完全阻止这些域扩展 .

我搜索了很多,发现了几个.htaccess重写规则,并以几种方式应用它们而没有结果 . 选项1和2放在.htacces文件的末尾 . 选项3位于#BEGIN和#END WordPress之间 .

我的分析中的推介链接示例如下:

  • 12342920-1.compliance-fred.xyz

  • buketeg.xyz

  • bukleteg.xyz

第一次尝试:

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://[^/]+\.xyz/? [NC,OR]
RewriteCond %{HTTP_REFERER} ^https://[^/]+\.xyz/? [NC,OR]
Rewriterule ^(.*)$ https://www.google.com [r=301,NC]

第二次尝试:

RewriteCond %{HTTP_REFERER} ^http://[^/]+\.xyz/? [NC]
Rewriterule ^(.*)$ https://www.google.com [r=301,NC]
RewriteCond %{HTTP_REFERER} ^https://[^/]+\.xyz/? [NC]
Rewriterule ^(.*)$ https://www.google.com [r=301,NC]

第三次尝试:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://[^/]+\.xyz/? [NC,OR]
RewriteCond %{HTTP_REFERER} ^https://[^/]+\.xyz/? [NC]
Rewriterule ^(.*)$ https://www.google.com [r=301,NC]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.mydomain.nl/$1 [R=301,L]
</IfModule>
# END WordPress