M
M
Margo19642016-08-21 10:16:47
Apache HTTP Server
Margo1964, 2016-08-21 10:16:47

How to configure htaccess to give each IP its own 403 response text?

Hello.
There is a code in .htaccess :

ErrorDocument 403 "Вы заблокированы"
Order Allow,Deny
Allow from all
Deny from 00.000.000.00

I think everything is clear here.
It is necessary that each ip has its own text for a 403 response:
Order Allow,Deny
Allow from all
Deny from 11.111.111.11 ErrorDocument 403 "Причина блокировки номер 1"
Deny from 222.222.222.222 ErrorDocument 403 "Причина блокировки номер 2"

How to do this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Margo1964, 2016-08-21
@Margo1964

Found a solution:

RewriteCond %{REMOTE_ADDR} ^000.00.00.000 [OR]
RewriteCond %{REMOTE_ADDR} ^111.11.11.111 [OR]
RewriteCond %{REMOTE_ADDR} ^222.22.22.222
RewriteCond %{REQUEST_URI} !(deny1.html) [NC]
RewriteRule (.*) /deny1.html [R=301,L]

RewriteCond %{REMOTE_ADDR} ^333.33.33.333 [OR]
RewriteCond %{REMOTE_ADDR} ^444.44.44.444
RewriteCond %{REQUEST_URI} !(deny2.html) [NC]
RewriteRule (.*) /deny2.html [R=301,L]

RewriteCond %{REMOTE_ADDR} ^555.55.55.555
RewriteCond %{REQUEST_URI} !(deny3.html) [NC]
RewriteRule (.*) /deny3.html [R=301,L]

N
Nazar Mokrinsky, 2016-08-21
@nazarpc

Logic is just for the code, make a simple page in your favorite programming language and give out any text. This is clearly overkill for htaccess.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question