Solved

Using filesMatch for multiple file types with auto_append_file

Posted on 2004-07-30
6
575 Views
Last Modified: 2010-03-04
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
Comment
Question by:hankknight
6 Comments
 
LVL 18

Expert Comment

by:CrYpTiC_MauleR
ID: 11683565
<FilesMatch "\.([^c][^s][^s][a-z0-9]+?)$">

you can try this...
0
 
LVL 16

Author Comment

by:hankknight
ID: 11687680
Thanks!  This is still not working for my .png, .gif and .jpg files.  

Any ideas why?
0
 
LVL 18

Accepted Solution

by:
CrYpTiC_MauleR earned 500 total points
ID: 11688482
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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 38

Expert Comment

by:yuzh
ID: 11691160
why not just use:

<FilesMatch \.(?i:gif|jpe?g|png|htm?l|php)$>
 
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 11692199
>  <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
 
LVL 16

Author Comment

by:hankknight
ID: 11694737
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question