I'm trying to send a custom header for pages that start with /test-live/
The code I tried:
<If "%{REQUEST_URI} =~ m#^/test-live/#">
Header always set X-Frame-Options "SAMEORIGIN"
</If>
As well as m#^/test-live/.*#
m#/test-live/.*#
m#^\/test-live\/.*#
Even simple %{REQUEST_URI} == '/test-live/'
doesn't work when I open /test-live/
page.
Apache is 2.4. And I passed %{REQUEST_URI}
to the browser, it seems correct. And the header is sent correctly outside of IF.
.htaccess
file - do you have a front-controller pattern? "I passed%{REQUEST_URI}
to the browser" - how?%{REQUEST_URI}e
No other header manipulation exists in .htaccess.htaccess
file with these directives in place.<If>
containers are merged late, despite the apparent order of directives in the config file, and if you have a front-controller pattern (as I suspect you might have) then the above<If>
expression will fail to match (since mod_rewrite is processed early). However, without seeing your complete config, I'm only guessing.%{REQUEST_URI}e
" -Header
directives and<If>
expressions are not executed at the same time - you are probably not testing like for like./test-live
a physical filesystem directory?