Score:1

RewriteCond for APIKEY

ad flag

I am trying to create a RewriteRule which looks at the incoming Header for an APIKey and if it contains a matching string then it will redirect to respective URL else, it should be inaccessible.

I am testing this scenario using postman with Post method.

Please find my code below:

RewriteEngine On
RewriteCond %{REQUEST_URI}  ^/manager/(.*)
RewriteCond %{REQUEST_URI}  ^/manager/secure/rest/groovy-service-invoke/v2/demo/firewall-test/v0.1.0/(.*)$
RewriteCond %{ENV:APIKEY}   ^ABCD123456789$
RewriteRule .* - [E:APIKEY=ABCD123456789]
Score:0
kz flag

To block access (ie. 403 Forbidden) to any URL-path that starts /manager/ when the HTTP request header APIKey is not supplied with the specific value (eg. ABCD123456789) you can use the following mod_rewrite rule:

RewriteEngine On

RewriteCond %{HTTP:APIKey} !=ABCD123456789
RewriteRule ^/?manager/ - [F]

:
RewriteCond %{ENV:APIKEY}   ^ABCD123456789$
RewriteRule .* - [E:APIKEY=ABCD123456789]

This isn't actually doing anything. It sets the environment variable APIKEY to the value ABCD123456789 but only when the env var APIKEY is already set to that value!

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.