RewriteHeader does not work at all

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 2
Joined: 16 Mar 2016, 15:50

RewriteHeader does not work at all

16 Mar 2016, 16:06

Hello,

I'm trying to use RewriteHeader to set some headers when loading a .png file.

To test this, I've set my entire .htaccess file to read as follows:

Code: Select all
RewriteEngine On
RewriteBase /

RewriteHeader MyHeader: .* "Hello this is working" [L]

Absolutely nothing happens. This header is nowhere to be found.

I have also tried removing the quotation marks to have the rule read:

Code: Select all
RewriteHeader MyHeader: .* Hello this is working [L]

This also does nothing.

My end goal is to be able to set Cache-Control headers on images that are loaded, but I cannot even get the most basic test example to work.

And yes, I have read the RewriteHeader documentation many times over.

I am using ISAPI_Rewrite 3 Release 3.1.0.105

The ISAPI_Rewrite 3 documentation does not provide even one actual example of the RewriteHeader rule in use, so I have no idea what I'm doing wrong. Any help would be greatly appreciated.

User avatar
Posts: 92
Joined: 01 Dec 2012, 14:22

Re: RewriteHeader does not work at all

12 May 2016, 16:12

Are you understanding that RewriteHeader will change *incoming* headers only? Do you have a "MyHeader" header coming in as part of the browser request? If not, this rule will never match anything.

If you want to change the values of headers that are part of the *output* from the page, I think you'll need to upgrade to Ape.

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: RewriteHeader does not work at all

13 May 2016, 09:18

Hello.

Yep, RewriteHeader is for incoming headers rewrite. ISAPI_Rewrite does not offer outgoing rewrites, however, Helicon Ape does. With Ape you actually have number of options, including mod_replace: https://www.helicontech.com/ape/doc/mod ... acePattern, mod_header: https://www.helicontech.com/ape/doc/mod ... htm#Header and since you've mentioned you need it for Cache-Control I suggest you to look into mod_expires instead: https://www.helicontech.com/ape/doc/mod_expires.htm
And read this article: http://www.helicontech.com/articles/mak ... rk-faster/ it may have the answers you actually need.

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 17 guests