¿Cómo puedo deshabilitar la autenticación básica HTTP en mi instancia de Apache para un REQUEST_URI específico?

¿Cómo puedo deshabilitar la autenticación básica HTTP en mi instancia de Apache para un REQUEST_URI específico?

Tengo una instancia de Linux que aloja un sitio de WordPress y tiene habilitada la autenticación HTTP básica para todo el sitio. Ahora quiero deshabilitar la autenticación HTTP básica para una ruta específica a la que podamos llamar /auth-free-url-2019.

Lo primero que pensé fue establecer una variable ENV en el .htaccessarchivo de la siguiente manera:

SetEnvIf REQUEST_URI "^/auth-free-url-2019" allowed_page=1

y luego agregando lo siguiente a mi autenticación

AuthUserFile SOME_AUTH_FILE
AuthName "AUTH NAME"
AuthType Basic
Order deny,allow
Deny from all
Satisfy Any
Require valid-user
Allow from all

Esto no funcionó y leí algo sobre mod_rewrite que posiblemente entrara en conflicto con las variables de entorno, así que decidí probar algo más simple agregando una <If>directiva en mi archivo .htaccess de la siguiente manera:

<If "%{REQUEST_URI} =~ m#auth-free-url-2019#i">
Order allow,deny

Satisfy Any
Allow from all
Deny from none

</If>
<Else>
Header set Checked-Request-url %{REQUEST_URI}e
AuthUserFile SOME_AUTH_FILE
AuthName "AUTH NAME"
AuthType Basic
Order deny,allow
Deny from all
Satisfy Any
Require valid-user
</Else>

Esto tampoco funciona y agregué un Header setpara ver el valor de REQUEST_URIy parece ser correcto.

En la <If>directiva lo he intentado

"%{REQUEST_URI} =~ m#auth-free-url-2019#i"
"%{REQUEST_URI} =~ /\/auth-free-url-2019$/i"
"%{REQUEST_URI} =~ /.*auth-free-url-2019.*/i"
"%{REQUEST_URI} == '/auth-free-url-2019'"
"%{REQUEST_URI} == 'auth-free-url-2019'"
"%{REQUEST_URI} == 'auth-free-url-2019'"
"-n %{REQUEST_URI}"

y solo el último desactivará la autenticación básica. No estoy seguro de cuál es el problema, pero por alguna razón, mis intentos de comparar con el valor REQUEST_URI no funcionan. Probé el mismo <If>bloque de directivas pero para HOST_NAME y parece funcionar, por lo que tiene algo que ver con REQUEST_URI.

Cualquier ayuda sería apreciada.

Apache 2.4.37

RHEL

y aquí está mi archivo .htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
</IfModule>


<If "%{REQUEST_URI} =~ m#auth-free-url-2019#i">

  Order allow,deny

  Satisfy Any
  Allow from all
  Deny from none

</If>
<Else>

  AuthUserFile SOME_AUTH_FILE
  AuthName "AUTH NAME"

  AuthType Basic
  Order deny,allow
  Deny from all
  Satisfy Any
  Require valid-user
  #Allow from all
</Else>


# Exclude the WP CRON and other scripts from authentication
<FilesMatch "(wp-cron.php|another-script.php)$">
  Satisfy Any
  Order allow,deny
  Allow from all
  Deny from none
</FilesMatch>

# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTPS} =on
    RewriteRule .* - [E=W3TC_SSL:_ssl]
    RewriteCond %{SERVER_PORT} =443
    RewriteRule .* - [E=W3TC_SSL:_ssl]
    RewriteCond %{HTTP:X-Forwarded-Proto} =https [NC]
    RewriteRule .* - [E=W3TC_SSL:_ssl]
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteRule .* - [E=W3TC_ENC:_gzip]
    RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
    RewriteRule .* - [E=W3TC_PREVIEW:_preview]
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
    RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
    RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]

</IfModule>

información relacionada