1

I've tried unsuccessfully to use the Apache FilesMatch directive to process all files as PHP. Using this <FilesMatch "\.html$">, I'm able to process specific file extensions as PHP, but I'm unable to find a directive that encompasses all file types, with our without extensions.

How can I configure Apache to parse all files for PHP content?

4

If you really mean what you say, that is, match ALL files, that would be something like:

<FilesMatch ^>

Try, but in any case I think this looks like a very bad idea. Better to be more specific, and match all cases "where" necessary.

  • Thanks for your answer, ezra-s. This is what I was looking for. The problem is I'm using a PHP script to fetch information on a 500 error by e-mailing extracts from relevant log files and referrer information from my Rails App. The server is configured to parse .html files for PHP code, but will not parse URLs like example.com/404 because the extension is missing. Sadly, while your answer is correct for the question, it doesn't help my situation. Thanks – Ralph Jan 17 '17 at 8:06
  • Another possibility would be using another directive: <Files *.*> – aldemarcalazans Oct 18 '19 at 21:04
1

I think this is it. Please try this

Options +FollowSymlinks +MultiViews 
RewriteEngine on
RewriteCond %{HTTP_HOST} ^urdom\.net [NC]
RewriteRule ^(.*)$ https://www.urdom.net/$1 [L,R=301]

I think this will let any file read with out the extension. *When using this there must not be a directory or a file name with same name even with different extension in the same directory

  • Thanks for responding. I'm not trying to parse only HTML files for PHP code, I'm trying to parse ALL files. – Ralph Jan 15 '17 at 15:58
  • If you are trying to execute files as php you can add the extensions you want to the above code. – Talal Al-Khalifa Jan 15 '17 at 16:05
  • That's the issue, the files don't have an extension. Ex: example.com/nil – Ralph Jan 15 '17 at 16:06
  • oh That is different. I use to do that but the files are all php but they are read without the extension. I will look in my old files if i find it I will post it here. I think it is not done with filesmatch – Talal Al-Khalifa Jan 15 '17 at 16:10
  • also add this to the options Options +FollowSymLinks +MultiViews I just tried it and it worked. Also you must note that the file can be show without the extension but actually you have to add it to the file. like www.dom.com/contact.php will be displayed as www.dom.com/contact – Talal Al-Khalifa Jan 15 '17 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.