403 And Banned Users - htaccess


#1

Hey,

All right atm I have my web site setup to block hotlinking. So when somone tries to hotlink they see my 403 error page.

Well lets say I ban someone. Well they still see the same 403 error page.

But instead I want banned uses to see a differnet 403 page if at all possiable.

Here is how I banned users for example:

order allow,deny
deny from 82.201.231.108
deny from 83.217.147.226
deny from 212.138.47.0
deny from 217.139.151.122
deny from 82.43.155.115
deny from 81.10.42.40
deny from 80.201.136.100
allow from all

So I dont want them to see the same 403 error page. I want them to see a banned user error page.

Any help with this would be great. I thought I could make an unarthorized.html file, but it does not seem to work.

Thanks,
Will

http://www.willsdownloads.com/


#2

Off the top of my head, you could send your 403 errors to a script that checks the reason for the error and prints out an appropriate response. It should be fairly simple to have the script parse .htaccess for the current list of banned IP addresses and compare the remote IP address to the list.

Another method might be to use Apache’s environment variables to set a variable if the remote address should not be allowed access, then use mod_rewrite to redirect them to your explanation page.


If you want useful replies, ask smart questions.


#3

Yet another method using environment variables is to use SSI (server-side includes) that create an if/else block. I had setup some pages up like that so that if someone purposely visited the document, it would tell them there was no error:

[code]

HTTP Error Document

This document is used to indicate an HTTP error.

Not Found

http://

[/code] Aslo, the status codes are: 401 - Authorization required (password-protected), default error document failed_auth.html 403 - Forbidden (Access denied), default error document forbidden.html

Using the ErrorDocument directive, you can use a different path and filename than the default.

:cool: Perl / MySQL / HTML CSS


#4

Thanks both of you.

I would pefer they way kchrist put it.

I’m completely new too all of this so…

That is I want to use mod_rewrite.

Put i need some help. Not a programmer here by nature.

Well so this is how I am thinking.

If REMOTE_ADDR == banned
{
dispaly banned page
}
else
{
display 403 errror page
}

#Banned User 403 Error
RewriteCond %{BANNED} .*
RewriteRule ^/$ /errors/banned.php [L]

#Normal 403 Error
RewriteRule ^/$ /errors/403.php [L]

Just thinking outloud. Or am I way off?

And some how make the banned variable and set it accordly.

Not really sure where to start. Like I said I just started in like the past two days even looking at anything even remotely related to this so I’m pretty lost. :frowning:

So any examples would be great.

Thanks again,
Will

http://www.willsdownloads.com/