Php – Apache htaccess .phps

.htaccessapache-2.2PHP

So I want the user to be able to run write "foo.phps" for a "foo.php" script in order to present the source of that file.

I only want to do this in one directory (since it's a security risk). Can I use .htaccess?

I added a .htaccess file to the directory and wrote this in it:

AddType application/x-httpd-php-source .phps

And then restarted Apache, but I can't add "s" to the file to get the source. Do I need to do something with PHP as well?

Best Answer

From the php docs, you need to use a SetHandler

<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>
Related Topic