Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is my .htaccess file - currently very limited for now, as it's a test site at:


AddHandler application/x-httpd-php .$

Is this syntax correct so that any file can be served extensionless and still run as a PHP one, in theory?

I'm fairly new to this, and would appreciate the help.

share|improve this question
It may not be wise to do this. Why do you need this? – Khaled Jan 29 '11 at 11:53
You really really really shound't do this, it's not a good idea – lynxman Jan 29 '11 at 12:05
Hey, folks, if you're going to tell someone it's not a good idea, it would be great if you could provide some documentation to back that up. Note that I'm not disagreeing; I just think that data is better than hearsay. – larsks Jan 29 '11 at 14:53

You can use a <FilesMatch> directive

<Filesmatch "^[^\.]+$">
    ForceType application/x-httpd-php

This can be placed in several different places depending on the scope that you want.

share|improve this answer

According to the AddHandler documentation, it doesn't appear to accept any sort of wildcard pattern, so I don't think that .$ is going to do anything other than match files that end with a literal .$.

If you want to set a default handler for all files in a directory, you're probably better off with the SetHandler directive.

Keep in mind that if you do something like this, you're limiting yourself to only servering PHP files from this directory...that means no images, no audio, no plain HTML; just PHP. It's unlikely that this is what you really want to do.

share|improve this answer

You can use mod_rewrite:

RewriteRule ^([^\.]+)$ $1 [T=application/x-httpd-php-source] 
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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