Topics: User Forum
Aug 25, 2008 at 3:11 PM

Sorry for my language but i don't speak well english...

I try to change the server name with RewriteHeader (1.2.15a version) but i don't find doc about this.

Like this :
RewriteHeader Server: .* no-name

...nothing append, the server name (microsoft-IIS/7) doesn't disappear in the client's response.

Thanks for helps.
Aug 25, 2008 at 4:33 PM

Yes, there's little doc on that particular feature.
The reason I haven't documented it is, I haven't completely tested it. This is what I want to put in the readme file:

RewriteHeader <header-name> <pattern> <replacement-string>   [<modifiers>]

This works much like the RewriteRule directive, except that it is an
HTTP Header that is being rewritten.  The <HEADER-NAME> must end with a
colon.  The <pattern> matches against the
value of the HTTP header specified.  The <REPLACEMENT-STRING>
and <MODIFIERS> work the same as in RewriteRule. 

If you want to simply set an arbitrary header, you can use a pattern of
.* , to match anything.  If you want this rule to apply only when the
header is empty, then use ^$ as the pattern.  

Back-refs and Server variables can be used in the replacement string,
just as with RewriteRule.  


  RewriteCond %{QUERY_STRING} ^$
  RewriteHeader Query-Is-Empty: .* YaHuh [L]

The rule above says to set the Header "Query-Is-Empty" to the value
"Yahuh" when the server variable QUERY_STRING is empty.

  RewriteCond %{QUERY_STRING} ^.+$
  RewriteHeader Query-Is-Not-Empty: .* YaHuh [L]

The rule above says to set the Header "Query-Is-Not-Empty" to the value
"Yahuh" when the server variable QUERY_STRING is NOT empty.

You should be careful with RewriteHeader directives.  They fall under the
same iteration rules as RewriteRule directives. When a RewriteHeader
rule matches, then evaluation of the URL / Request starts all over again
with the current ruleset, subject to the iteration limits described
elsewhere in this documentation. 

What this means is, you can inadvertently "mask" your RewriteRule
directives with a poorly constructed RewriteHeader directive.  For
example, in the directives above, I set the header always.  A better
approach would be to set the header only if it is not already set.  For

  RewriteCond %{QUERY_STRING} ^.+$
  RewriteHeader Query-Is-Not-Empty: ^$ YaHuh

The interesting bit is, the header is set on the server side. So if your server app (let's say it is a JSP app, or a PHP app) lists the incoming headers, it will see the header you have set. But the response, sent to the client, has a different set of headers. So if you expect to see the header you set, in the response sent to the client, I think that is not the way it works.

I think there may be a way to do what you want in a filter, but IIRF does not yet do that. I have to examine it further.

Aug 25, 2008 at 4:41 PM
There is a way for a filter to add a header to the outgoing response.
I haven't examined it so I don't know if it would work for your purposes.
I presume the outgoing response headers are set by the application behind the filter.
If I were to make this change in IIRF, to allow it to set response headers, there is no guarantee that the headers would remain on the response.
I would guess that whether the header set by IIRF remains, would depend on the upstream application, and whether it clears or overwrites existing headers.