F
F
full-size2021-05-21 07:46:34
htaccess
full-size, 2021-05-21 07:46:34

How to register a referrer ban in .htaccess?

Good afternoon!
The situation is this. There is a WordPress site in which a ban on certain referrers is registered in the root .htaccess file:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} ok.ru [NC,OR]
RewriteCond %{HTTP_REFERER} mamba.ru [NC,OR]
RewriteCond %{HTTP_REFERER} facebook.com [NC]
RewriteRule .? - [F,L]
Everything works, but, on the site, due to the need, two separate WordPress cms are installed, one in the root of the site, where the above construction is written, the other cms in the /doma/ folder.

The .htaccess in the /doma/ folder contains the following:
AddDefaultCharset UTF-8

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /doma/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /doma/index.php [L]
</IfModule>
# END WordPress
With all this, referrer restrictions do not work for the /doma/ folder and all site pages from this directory.

Can you please tell me what and where should be written so that the above restrictions on the referrer also work for the pages of the /doma/ directory site? I would be grateful if you could help with the finished design.

Thank you in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-05-21
@dodo512

FILE /doma/.htaccess

AddDefaultCharset UTF-8

RewriteEngine On

RewriteCond %{HTTP_REFERER} ok\.ru [NC,OR]
RewriteCond %{HTTP_REFERER} mamba\.ru [NC,OR]
RewriteCond %{HTTP_REFERER} facebook\.com [NC]
RewriteRule ^ - [F]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /doma/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /doma/index.php [L]
</IfModule>
# END WordPress

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question