Custom 403?


#1

I guess there’s no way to make a custom access denied page, is there? I have certain IPs I’ve denied access to and would like to give a little more information than what is shown with a generic 403. I have customized the forbidden.html page but when an IP is denied, this page doesn’t show. A generic access denied page is shown instead. I guess I can understand why, I’m just wondering if there’s a way to show more information to those I’m denying access to.

NOTE: I know how to make custom error pages - it’s a 403 to IPs being denied access that I want to customize.


#2

Why not create a script then? Use the script that will look up their IP address and output different results.

That’s perfectly possible. ErrorDocument doesn’t have to point to a static HTML file. :wink:


#3

Thanks for your reply, guice.

LOL… If I knew how to create one, I would! Hence, the reason I’ve posted in the “Beginner’s Forum.”

I deny access to many IPs (not to mention several countries). I am just now learning PHP basics so creating a script for this is a little beyond me.

This statement is in conjunction with making a script, correct? So if I create a script, it will run even though access has been denied? Or, would I not deny access via .htaccess file. Instead would I have a separate file with denied IPs that would be redirected to a script that would have a customized message? See how complex this is? :slight_smile:


#4
order allow,deny allow from all

Save $96 dollars when you sign up! -> 96DISCOUNT :wink:


#5

[quote]
order allow,deny
allow from all
[/quote]
Thanks Zen. My first guess would be that I should add the IPs like this:

order allow,deny
###.##.##.##
###.##.##.##
allow from all

Is that correct? Something tells me it isn’t.


#6

From your first post I’m suposing that you already have specific IPs blocked on your .htaccess file ("…I have certain IPs I’ve denied access to…") and then you would just have to add the snippet to it.

It says that forbidden.html is allowed to everyone, even those blocked IPs.


Save $96 dollars when you sign up! -> 96DISCOUNT :wink:


#7

Ah! Got it. Yes, I am already blocking IPs. I didn’t realize I could add the filename there. That’s what I wanted. Thanks so much!


#8

You can put in :-
deny from 192.192.192.192
to ban one IP address.

You can go further down the range by leaving blocks off.
deny from 192.192.192.

etc.

You should be able to serve up a page to a particular IP using a rewrite section using
RewriteCond %{REMOTE_ADDR} and the IP address

But someone more skillied will have to finish the rule. :slight_smile:


Norm


#9

:wink: No problem!


Save $96 dollars when you sign up! -> 96DISCOUNT :wink:


#10

Thanks Norm. Believe me, I learned fast how to deny IP blocks. :slight_smile: Zen gave me the answer to what I was looking for. That should work fine.

Hope


#11

[quote]
order allow,deny
allow from all
[/quote]
Zen,

This is not working for me. What seems to be happening is that the IP list is only being denied from the file forbidden.html. I should have guessed this because I actually have similar for <Files .htaccess> disallowing anyone access to my .htaccess. Is there another way to do this? If I reverse it such as:

order deny,allow
deny from all

Would that keep the banned IPs out of the rest of the site or would it keep all IPs other than the banned list out of the site?


#12

So I guess I’m back to my initial post - that this cannot be done (other than with a script), - correct? Anyone?


#13

Sorry, thought that would work… it didn’t.


Save $96 dollars when you sign up! -> 96DISCOUNT :wink:


#14

It is possible to hack in a rewrite rule for it. But other than that, correct.

Try:

I’m just typing this off the top of my head. If you get a 500 error, means there’s a syntax error somewhere.


#15

Thanks guice. Unfortunately, I think I have way too many IPs for that.

Hope


#16

That many? Then it’s script time.


#17

Yes, that many. I hate rogue bots and scrapers. I’m sure there are many out there who love them but… not I.


#18

This is in the wrong order. the order allow,deny says that all from all will be before the deny from lines.
You can either move the allow from all and place it before the deny from ip 's or reverse the order to say order deny,allow
The rest is out of my league
Silk


#19

[quote]This is in the wrong order. the order allow,deny says that all from all will be before the deny from lines.
You can either move the allow from all and place it before the deny from ip 's or reverse the order to say order deny,allow
The rest is out of my league[/quote]
Thanks for the reply. I don’t think I tried reversing the order to deny, allow because I figured that would deny all but the banned IPs from the site/and or page in question and wouldn’t bring about the desired results…unless I want a bunch of scrapers and hackers. :slight_smile:


#20

Order doesn’t matter in this case cause all you’re doing is setting the permissions on that one file. That’s it.