Alan Doherty
Alan Doherty

Reputation: 117

how do i modify the first returned header on the fly

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

Upvotes: 0

Views: 277

Answers (2)

Jim
Jim

Reputation: 73966

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.

Upvotes: 1

Erik Bakker
Erik Bakker

Reputation: 4589

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.

Upvotes: 0

Related Questions