Apache : Inject HTTP response header in a rewrited URL using environment variable
I've spent a few hours looking for a way to inject HTTP response
headers in a rewrited URL directly from the Apache
configuration.
Here's the trick, in the RewriteRule just set a environment
variable, ie: "addheader".
But unfortunately, this one can't be used as-is as a condition in
the "Header" directive. In this case you'll need to rely on the
presence / absence of the "REDIRECT_addheader" :
RewriteEngine On
RewriteRule ^([A-Z]{2})_([a-z]{2})$ /rewrite.php?a=$1&b=$2 [L,E=addheader:1]
Header set my-header "myvalue" env=REDIRECT_addheader
Puppet Talk @ Journées du Logiciel Libre 2011
Here are the slides of the talk I've given at Journées du Logiciel Libre yesterday in Lyon (Download)
Parse .ini files with bash and sed
Here's a very cool way to parse ini files inside a shell
script.
The following snippet will declare variables in the current scope
of your script from all the key/values pairs present in the
matching section.
#!/bin/bash
CONFIG_FILE="config.ini"
SECTION="section_1"
eval `sed -e 's/[[:space:]]*\=[[:space:]]*/=/g' \
-e 's/;.*$//' \
-e 's/[[:space:]]*$//' \
-e 's/^[[:space:]]*//' \
-e "s/^\(.*\)=\([^\"']*\)$/\1=\"\2\"/" \
< $CONFIG_FILE \
| sed -n -e "/^\[$SECTION\]/,/^\s*\[/{/^[^;].*\=.*/p;}"`







