0

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

http://localhost/mydomain/testfile

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.

3
  • It may not be wise to do this. Why do you need this?
    – Khaled
    Jan 29, 2011 at 11:53
  • You really really really shound't do this, it's not a good idea
    – lynxman
    Jan 29, 2011 at 12:05
  • 1
    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, 2011 at 14:53

3 Answers 3

1

You can use a <FilesMatch> directive

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

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

0

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.

0

You can use mod_rewrite:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .