Page 1 of 1

I need something like "ErrorDocument 200" in .htac

Posted: Wed Apr 19, 2006 3:59 pm
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

Posted: Wed Apr 19, 2006 5:57 pm
by tomfra
Nobody knows? Even crazy ideas are welcome :lol:

Tomas

Posted: Thu Apr 20, 2006 12:40 pm
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...)

Posted: Thu Apr 20, 2006 12:50 pm
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

Posted: Thu Apr 20, 2006 1:15 pm
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...