0

Currently when I want to block an IP in .htaccess, I use:

deny from 192.168.1.1

It produces 403 (Access Denied) response.

My question is - would it be possible to have 410 response instead of 403? Ie. would this be proper to use?

deny from 192.168.1.1 [G,L]

(G - gone = 401 response), (L - last execution, don't look any further)

I found some idea here - HTACCESS / ErrorDocument - How to serve 410 instead of 403 but it covers all denied IPs; here, I'd like to use 410 response only for selected IPs (that's why I was hoping that adding [G,L] by them would make sense and be the easiest solution, if it's proper..

Tomasz
  • 1,288
  • 18
  • 36

1 Answers1

1

I would suggest redirecting, which lead to the desired error code:

RewriteCond %{REMOTE_ADDR} 1.2.3.4
RewriteRule .* /CustomError.html [R=410]

But you also could make that 403 present an HTML saying it's a 410 error:

<Location /server-status>
    SetHandler server-status
    Order Allow,Deny
    Deny from  all
    Allow from 192.168.16.0/24
    ErrorDocument 403 /dir/test.html
</Location>

And in test.html just write:

<p>Error 410</p>
Miguel Ortiz
  • 1,412
  • 9
  • 21