?
Solved

Using filesMatch for multiple file types with auto_append_file

Posted on 2004-07-30
6
Medium Priority
?
612 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

718 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