I need something like "ErrorDocument 200" in .htac

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
tomfra
Forum Contributor
Posts: 126
Joined: Wed Jun 23, 2004 12:56 pm
Location: Prague, Czech Republic

I need something like "ErrorDocument 200" in .htac

Post by tomfra »

I know I can use ErrorDocument 403, ErrorDocument 404 etc to redirect all requests with the given status / error code to a page (or PHP script) I want such as:

ErrorDocument 403 /error.php

But I need a solution that will execute a PHP script for all "200 OK" requests. I know about "php_value auto_prepend_file" but that works for PHP files only.

What I want to accomplish is to check whether the user is allowed access to my website based on criteria such as their IP address. The check itself needs to be handled by a PHP script. It will be up to the PHP script to decide whether the user is allowed access or not so Apache should send all requests (including the "200 OK" ones) to it.

Any ideas?

Tomas
tomfra
Forum Contributor
Posts: 126
Joined: Wed Jun 23, 2004 12:56 pm
Location: Prague, Czech Republic

Post by tomfra »

Nobody knows? Even crazy ideas are welcome :lol:

Tomas
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

We'" not a hotline/immediate response community :p

(The only way i see right now is to add a custom proxy that maps all requests to the php script and then forwards to apache...)
tomfra
Forum Contributor
Posts: 126
Joined: Wed Jun 23, 2004 12:56 pm
Location: Prague, Czech Republic

Post by tomfra »

[quote="timvw"]We'" not a hotline/immediate response community :p[quote]

Actually, most of the time this community finds the answers much faster than just about any hotline :lol:

I'll probably use the "php_value auto_prepend_file" I mentioned, despite it will somewhat limit what I would like to achieve. I'll play with the "proxy idea" too.

Thanks!

Tomas
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

With mod_rewrite you can redirect all requests to your script... And if you rewrite to /myscript.php?original=$1 you know where to forward after the request...
Post Reply