Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use SetEnvIf based on matches in the query string?

The URL I'm using is, let's say, example.com/subdir/index.php?foo=bar

index.php contains this: <?php echo getenv("testenvvar"); ?>

I'm setting an enviroment variable in .htaccess like so:

SetEnvIf Request_URI (index) TestEnv=Worked

This prints "Worked".

If I change it to SetEnvIf Request_URI (bar) TestEnv=Worked, it does not.

How can I do this?

like image 669
Duncan Marshall Avatar asked Jul 10 '15 13:07

Duncan Marshall


1 Answers

Another option would be SetEnvIfExpr:

SetEnvIfExpr "%{QUERY_STRING} =~ /bar/" TestEnv=Worked
like image 195
Kevinoid Avatar answered Sep 26 '22 14:09

Kevinoid