daveberk:
I want to identify files that do NOT have an extension so they can be parsed for PHP. This is for a web site .htaccess file running on a Linux/Apache web server.
I have tried to filter for files not containing a dot (.)
Code I have tried is:
<FilesMatch "[^.]*">
ForceType application/x-httpd-php
</FilesMatch>
From Apache.org about the <filesMatch> directive:
The <FilesMatch> directive provides for access control
by filename, just as the <Files>
directive does. However, it accepts a regular expression. For
example:
<FilesMatch "\.(gif|jpe?g|png)$">
would match most common Internet graphics formats.
If you look closely at watch you have and the website example you might see what the problem is, boundries
What you have is unbounded and will match anything not a period. That doesn't mean the input won't contain a period just that the period wont be included in the match or matches. The regex would just match around the periods.
Since the web site sample include a boundary I'm guessing they aren't implied with is the norm.
try
^[^.]+$
I used the + instead of * because I would think the filename would at least have to be one character. If an empty string is also a good match change the + back to a *
Also beware that is regex would allow values that are illegal for file names so you'd have to come up with a stricter regex to check for allowable file naming characters.
Michael
Michael
"In theory, theory and practice are the same. In practice, they are not."
Albert Einstein