tags:

views:

103

answers:

2

i mean the HTTP/1.1 xxx yyyyyyy

header i can modify all others with mod_headers but want to be able to return a status 200 for 403 error pages to a particular user-agent that dosn't display the text of my 403 pages {it displays an alternate page}

just asking if anyone knows an env-var or header name i can alter in apache.conf to alter this header in any way {once i have that i can work out the making it user-agent specific bits

A: 

You could set up a php script for your 403 error page and modify the header with that script:

Put a line like this in your .htaccess or Apache configuration file:

ErrorDocument 403 /path/to/your/error/script.php

And the following in said php file:

<?php
if($_SERVER['HTTP_USER_AGENT'] == 'FooBot 1.2') {
  header("HTTP/1.0 200 OK");
}
?>

Or do the same thing in your preferred language.

eamelink
it is looking like the only option but would prefer to default serve html rather than php as the overhead of processing php {from tests} is quite large when 99% of 403 requests goto previously banned and malicious bots
Alan Doherty
currently demoing your solution on www.alandoherty.netand yes it does allow the custom 403 page to be rendered on Google Wireless Transcoderwww.google.com/gwt/mbut waiting to see if anyone knows a way to do this via http.conf mod_headers or other if not i'll mark your answer as best
Alan Doherty
current php solution signifigantly slower but working{offloaded user agent detection to apache for speed}httpd.conf "SetEnvIfNoCase User-Agent "Google\ Wireless\ Transcoder" google-proxy"thus in php "if (isset($_SERVER['google-proxy'])) header("HTTP/1.0 200 OK");"as it signifigantly speeds
Alan Doherty
but the same content in shtml Time per request: 0.880 [ms] (mean) Time per request: 0.880 [ms] (mean, across all concurrent requests) vs php Time per request: 1.170 [ms] (mean)Time per request: 1.170 [ms] (mean, across all concurrent requests)
Alan Doherty
That sounds interesting. I suggest you post your best solution as an answer as well so others can find it more easily!
eamelink
well till another solution better than php turns up this is it atmbut can't see why apache wouldn't offer this via some module/tweak{which would take out the vastly slower php neccesity}
Alan Doherty
+1  A: 

That is not a header, it is the status line.

Lying about the status of responses can often cause problems, for example, link checkers would miss reporting such errors. You are relying on a human reading the 200 page and understanding it, but the whole point of computer protocols is that they can be understood by computers as well. You should try to fix the problem instead of hiding it.

It sounds to me like you have run across Internet Explorer's insistence upon "friendly" error pages. You can work around that by padding out your error page so that it is larger than 512 bytes, which then causes Internet Explorer to display the error page instead of its own.

Jim
actually no all user agents bar 1 show the custom 403 page that allows the previously malicious and banned ip to un-block themselves via capachabut the "google mobile transcoder" useragent dosn't return the 403 to the user it gives "page unavailable or server down"
Alan Doherty
if it {and only it} got a "HTTP/1.1 200 OK" instead it would display the text of the "your ip is blacklisted because....and heres how to re-gain access" pagegoogle mobile transcoder {and the poor phone users stuck with it} are the only reason to do this
Alan Doherty
currently i just don't ban {whitelisted} those ip's but the downside is {pretty much}all harvesters are now using it to avoid these automated bad-spider detection/defence systems
Alan Doherty