Adding a header to a number of requested urls

Discussion in 'Apache' started by rabisco, Oct 23, 2014.

  1. #1
    I am attempting to add a header to a number of requested urls i.e. domain/feeds/chicago, domain/feeds/*
    I understand that this can be achieved by

    •using mod_rewrite to set an environment variable
    •using mod_headers to add a header based on the existence of an environment variable.

    So far I can add the a new header thus

    Header add RSS_FEED_URL "Akamai-Edge-Control"

    I'm looking for some pointers as to how to achieve this.
     
    rabisco, Oct 23, 2014 IP
  2. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #2
    You could try something like:

    
    # Untested, but play around with the flags, it may work
    RewriteRule ^/feeds/([\w\d_-]+)$ /feed.php?name=%1 [PT,QSA,E=akamai:1]
    
    Code (markup):
    That will pass the processing of feed requests to a PHP script called feed.php where you could do a getenv('akamai'), and whatever other checks you need to do.

    Something like:

    
    <?php
    if (getenv('akamai') == 1)
    {
      header("RSS_FEED_URL: Akamai-Edge-Control");
    }
    ?>
    
    PHP:
     
    zacharooni, Dec 21, 2014 IP