I'm trying to detect the presence of a particular name/value pair in the query string and, if it exists, do a thing. I'm trying to do this in a conf file that's stored in conf-available/
and after a2enconf
has been run to enable it. The code is small:
RewriteCond %{QUERY_STRING} foo=bar [NC]
RewriteRule ^(.*)$ http://linkedin.com [R=301,L]
No, redirecting to linkedin (or anywhere else) isn't my final goal, but I wanted to make it do something very obvious just to know that it's working (it's not, obviously). Just to verify that this conf is loaded and its code is being exercised, I added the following snippet right above:
RedirectMatch 301 ^(.*)$ http://www.cnn.com$1
The RedirectMatch
works as expected. The RewriteRule
does not.
Apache is running inside of a docker container and my local :8080 is forwarded to :80 on the container. I'm trying to access the site at http://localhost:8080?foo=bar
. If I move this exact same code to a .htaccess
file, it works exactly as expected.
Am I too far in the weeds here and missing something obvious?
UPDATE
Full conf file below:
<IfModule mod_rewrite.c>
RewriteEngine On
# Verifies that this conf is loading properly
# RedirectMatch 301 ^(.*)$ http://www.cnn.com$1
RewriteCond %{QUERY_STRING} foo=bar [NC]
RewriteRule ^(.*)$ http://linkedin.com [R=302,L]
</IfModule>