Pregunta

I have a script that is automatically adding IP addresses to my.htaccess file based on lookups in spam databases. However, I would like for subsequent visits from those addresses to be able to view a 403 ErrorDocument I create. Obviously, though, they cannot, as they have been denied. My .htaccess looks like this:

ErrorDocument 403 /403.php

deny from <ip address>
deny from <ip address>
deny from <ip address>
deny from <ip address>
yada yada yada

Any suggestions on how to do this? I am adding the addresses via PHP.

Thanks in advance.

¿Fue útil?

Solución

You have two way:

  1. ErrorDocument 403 http://www.yourdomain.com/403.php
  2. ErrorDocument 403 "Go and Do NOT return!"

of course, First one will redirect user!
If you have particular file formats on your site(like .php,.txt,.xml,.htm,...) you can use this one but I DO NOT recommend it!

<Files ~ "\.(inc|sql|.php|.html)$">
  order allow,deny
  allow from all
  deny from 127.0.0.1
</Files>

Update: As Sean Kimball mentioned you can use rewrite mod (of course it's possible,it's Apache)

RewriteCond %{REMOTE_ADDR}  ^127\.0\.0\.1$
RewriteRule (.*)  403.php

Otros consejos

I would think a rewrite rule would be more appropriate - though I'm not 100% sure you can redirect based on an ip address. You would need to check the mod_rewrite docs.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top