Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.apache.configuration > #4268 > unrolled thread

Setting header based on %{REQUEST_URI}

Started byijunaidsubhani@gmail.com
First post2015-12-02 17:43 -0800
Last post2015-12-07 13:50 -0800
Articles 3 — 3 participants

Back to article view | Back to alt.apache.configuration


Contents

  Setting header based on %{REQUEST_URI} ijunaidsubhani@gmail.com - 2015-12-02 17:43 -0800
    Re: Setting header based on %{REQUEST_URI} Kees Nuyt <k.nuyt@nospam.demon.nl> - 2015-12-03 11:30 +0100
      Re: Setting header based on %{REQUEST_URI} "D. Stussy" <spam@spam.org> - 2015-12-07 13:50 -0800

#4268 — Setting header based on %{REQUEST_URI}

Fromijunaidsubhani@gmail.com
Date2015-12-02 17:43 -0800
SubjectSetting header based on %{REQUEST_URI}
Message-ID<fdf035bc-bbf1-424c-b070-a251996fcba5@googlegroups.com>
Hi guys,

I am trying to Set a particular Header and its value based on a %{REQUEST_URI}.

I am trying to set a header based on the URI of a particular page. 

1. I access a page using chrome.
2. Inspect element and see that my URI header is giving the value /bst/index.html
3. Now in my Apache config , I want to set a Header to Yes if my %{REQUEST_URI} is equal to /bst/index.html

This is what I am doing :

    RewriteCond %{REQUEST_URI} ^\/bst\/index\.html [NC]
    Header set X-Akamai Yes

The above config is not working and is setting X-Akami for all the pages I am visiting on the web page. 

Any idea why ? 

[toc] | [next] | [standalone]


#4269

FromKees Nuyt <k.nuyt@nospam.demon.nl>
Date2015-12-03 11:30 +0100
Message-ID<9o506btucr26d4pb55rura7h7ddva7cauv@dim53.demon.nl>
In reply to#4268
On Wed, 2 Dec 2015 17:43:16 -0800 (PST), ijunaidsubhani@gmail.com
wrote:

> Hi guys,
>
> I am trying to Set a particular Header and its value based on a %{REQUEST_URI}.
>
> I am trying to set a header based on the URI of a particular page. 
>
> 1. I access a page using chrome.
> 2. Inspect element and see that my URI header is giving the value /bst/index.html
> 3. Now in my Apache config , I want to set a Header to Yes if my %{REQUEST_URI}
>    is equal to /bst/index.html
>
> This is what I am doing :
>
>    RewriteCond %{REQUEST_URI} ^\/bst\/index\.html [NC]
>    Header set X-Akamai Yes
>
> The above config is not working and is setting X-Akami for all the pages I am visiting on the web page. 
>
> Any idea why ? 

Warning: I'm not an expert ;) Anyway, I don't think rewrite does
anything useful here.

Maybe you should try:

  SetEnvIf Request_URI ^\/bst\/index\.html XAKA=1
  Header set X-Akamai Yes env=XAKA



http://httpd.apache.org/docs/2.2/mod/mod_setenvif.html#setenvif
http://httpd.apache.org/docs/2.2/mod/mod_headers.html#header

Hope this helps.
-- 
Kees Nuyt

[toc] | [prev] | [next] | [standalone]


#4274

From"D. Stussy" <spam@spam.org>
Date2015-12-07 13:50 -0800
Message-ID<n44uum$hbr$1@snarked.org>
In reply to#4269
"Kees Nuyt"  wrote in message 
news:9o506btucr26d4pb55rura7h7ddva7cauv@dim53.demon.nl...
On Wed, 2 Dec 2015 17:43:16 -0800 (PST), ijunaidsubhani@gmail.com wrote:
> I am trying to Set a particular Header and its value based on a 
> %{REQUEST_URI}.
>
> I am trying to set a header based on the URI of a particular page.
>
> 1. I access a page using chrome.
> 2. Inspect element and see that my URI header is giving the value 
> /bst/index.html
> 3. Now in my Apache config , I want to set a Header to Yes if my 
> %{REQUEST_URI}
>    is equal to /bst/index.html
>
> This is what I am doing :
>
>    RewriteCond %{REQUEST_URI} ^\/bst\/index\.html [NC]
>    Header set X-Akamai Yes
>
> The above config is not working and is setting X-Akami for all the pages I 
> am visiting on the web page.
>
> Any idea why ?

Warning: I'm not an expert ;) Anyway, I don't think rewrite does anything 
useful here.

Maybe you should try:

  SetEnvIf Request_URI ^\/bst\/index\.html XAKA=1
  Header set X-Akamai Yes env=XAKA

==================================
Agreed that this will work, but it will do it pretty much universally for 
all virtual hosts, and the backslash is unnecessary.

The problem with the OP's attempt is a misunderstanding on how the rewrite 
engine works.  RTFM.  What was needed was this:

RewriteRule    ^/bst/index\.html$    -    [NC,E=XAKA:1]
Header set X-Akamai Yes env=XAKA

This is closer to what the OP asked.

[toc] | [prev] | [standalone]


Back to top | Article view | alt.apache.configuration


csiph-web