Hello,
How do I find out what's going on here? I've reduced this to a very simple situation to demonstrate the oddity.
I have this real, actual (it appears listed in my FTP app) file here:
domain.com/c/test.css.php
In this file:
domain.com/.htaccess
I have:
CookieTracking off
Options -Indexes -MultiViews
Header set MyHeader "Hello"
RewriteEngine On
RewriteRule ^([^.]+)\.css$ /$1.css.php [NC,L]
This works fine when I access
http://www.domain.com/c/test.css
in a browser. That is, the domain.com/c/test.css.php file is accessed fine, and, it has the MyHeader set for it.
(Note: I'm just setting a header here for test purposes, because it seems like a very simple apache command -- so setting a header isn't my actual end goal. That apache line will be SetOutputFilter DEFLATE in the proper version but I'm just trying to work out why the various targetting methods aren't working at the moment)
But I want to restrict the MyHeader to either just the domain.com/c/ directory or to just files which end with .css.php
First I try moving
Header set MyHeader "Hello"
from the root .htaccess to a new .htaccess file here:
domain.com/c/.htaccess
Doesn't work; No header on access to
http://www.domain.com/c/test.css
(nor on access to
http://www.domain.com/c/test.css.php
for that matter).
Why might that not be working?
Second I try a different way. I go back to the original set up (the header line in the .htaccess in the root directory and deleting the domain.com/c/.htaccess file) but changing the .htaccess to this:
CookieTracking off
Options -Indexes -MultiViews
<FilesMatch "\.css\.php$">
Header set MyHeader "Hello"
</FilesMatch>
RewriteEngine On
RewriteRule ^([^.]+)\.css$ /$1.css.php [NC,L]
Doesn't work. I try (I'll just repeat the FilesMatch part from now on):
<FilesMatch "\.css(\.php)?$">
Header set MyHeader "Hello"
</FilesMatch>
Doesn't work. I try:
<FilesMatch "\.php$">
Header set MyHeader "Hello"
</FilesMatch>
Doesn't work. I try:
<FilesMatch "\.css$">
Header set MyHeader "Hello"
</FilesMatch>
Doesn't work. I try:
<FilesMatch "\.php">
Header set MyHeader "Hello"
</FilesMatch>
Doesn't work. I try:
<FilesMatch "\.css">
Header set MyHeader "Hello"
</FilesMatch>
Doesn't work. I try:
<FilesMatch "php$">
Header set MyHeader "Hello"
</FilesMatch>
Doesn't work. I try:
<FilesMatch "php">
Header set MyHeader "Hello"
</FilesMatch>
It works. That is I get the header on requests to
http://www.domain.com/c/test.css
It doesn't seem a very satisfactory way to make it work. The regex pattern of just "php" seems far too broad. Why might none of the previous attempts work?
Thanks.