apache.htaccesswebsites

As traffic block a website with .htaccess?


Hello everyone I found this code .htaccess to block a website, but do not understand why in the first line is [NC, OR] and the second link does not? So okay if I want to block traffic 2 or more websites?

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} lsale02\.ru [NC,OR]
RewriteCond %{HTTP_REFERER} esoqld.ru\.ru  <------- **does not have [NC,OR]**
RewriteRule .* - [F]

Solution

  • If you want to deny access to more websites, add more like below. Small notice, every point needs to be escaped:

    RewriteEngine on
    # Options +FollowSymlinks
    RewriteCond %{HTTP_REFERER} lsale02\.ru [NC,OR]
    RewriteCond %{HTTP_REFERER} another\.ru [NC,OR]
    RewriteCond %{HTTP_REFERER} esoqld\.ru\.ru [NC]   # last one doesn't need OR because there will be no more conditions.
    RewriteRule .* - [F]  # returns a 403 [F]orbidden