Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 620
  • Last Modified:

Using filesMatch for multiple file types with auto_append_file

I currently use the following in my .htaccess file to log visits to html files in a given directory.

               <FilesMatch "\.(html?)$">
               php_value auto_append_file "/usr/home/myspace/WWW/html/count.php"
               </FilesMatch>

I want it to log ALL files except .css files.

This includs (but is not limited to):
          .jpg
          .gif
          .png
          .html
          .htm
          .php

Can I have it log all files EXCEPT ones that end with .css?

If not, do I have to list all posible extentions out right?

Thanks!
0
hankknight
Asked:
hankknight
1 Solution
 
CrYpTiC_MauleRCommented:
<FilesMatch "\.([^c][^s][^s][a-z0-9]+?)$">

you can try this...
0
 
hankknightAuthor Commented:
Thanks!  This is still not working for my .png, .gif and .jpg files.  

Any ideas why?
0
 
CrYpTiC_MauleRCommented:
Are the images coming up? I have never tried including a file into an image, seeing that it might corrupt the image file and make it not display.

Try this slight variation....

 <FilesMatch "\.([^c][^s][^s][a-z0-9]?)$">

Should allow any 3-4 character extension and not allow .css


Also do this...

<Files ~ "\.([^c][^s][^s][a-z0-9]?)$">
ForceType application/x-httpd-php
</Files>


So it allows the PHP engine to parse any file except .css otherwise image files wont have PHP engine include the file.
Keep me posted on the progress, once this gets figured out will probably use it on my site too =oP. Good luck!
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
yuzhCommented:
why not just use:

<FilesMatch \.(?i:gif|jpe?g|png|htm?l|php)$>
 
0
 
ahoffmannCommented:
>  <FilesMatch "\.([^c][^s][^s][a-z0-9]?)$">
>  Should allow any 3-4 character extension and not allow .css

no.
does not allow .asa for example

I'd go with a white list as suggested by yuzh
0
 
hankknightAuthor Commented:
CrYpTiC_MauleR Said:
-----------------------------------------------------
               <Files ~ "\.([^c][^s][^s][a-z0-9]?)$">
               ForceType application/x-httpd-php
               </Files>
-----------------------------------------------------

Thanks!  This is what I needed.  I thought that the trouble was with my regular expressions but the problem was  because the images weren't being touched by PHP, the php_value auto_append_file command did nothing.

Now I need to evaluate the security implications of processing most filetypes as php scripts...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now