简体   繁体   中英

Block spam using .htaccess wildcard for subdomain

I have a lot of spam coming from one site with multiple subdomains and currently I am blocking them using individual lines as below

RewriteCond %{HTTP_REFERER} site1.floating-share-buttons.com [NC,OR]
RewriteCond %{HTTP_REFERER} site2.floating-share-buttons.com [NC,OR]
RewriteCond %{HTTP_REFERER} site3.floating-share-buttons.com [NC,OR]
RewriteCond %{HTTP_REFERER} site4.floating-share-buttons.com [NC,OR]
RewriteCond %{HTTP_REFERER} site5.floating-share-buttons.com [NC,OR]

How can I use or what is the wildcard for the sub-domain part so I can achieve the same thing using just one line.

Use regex alternation:

RewriteCond %{HTTP_REFERER} (site1|site2|site3|site4|site5)\.floating-share-buttons\.com [NC]

Or else if names are site1,site2,..site5 then:

RewriteCond %{HTTP_REFERER} site[1-5]\.floating-share-buttons\.com [NC]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM