I have a section on my server with public php snippets. I would like to have index.php execute but not other php files. I have attempted to set Unix file permissions but since php files are read only 644 anyway this is not the solution. I have tried various combinations of the .htaccess settings shown here and get for different results. 1) all php file download 2) all php files are forbidden 3) all php files execute 4) index executes but other php are forbidden What I am hoping for is to have all but index.php shown as a text file. Thanks for the help <FilesMatch "\.(htm|html|php)$"> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch "\.php$"> Order Allow,Deny Deny from all </FilesMatch> <FilesMatch "index\.php$"> Order Allow,Deny Allow from all </FilesMatch> <FilesMatch "index.php$"> Order Allow,Deny Allow from all </FilesMatch>
I'm not sure what you exactly wanted AFTER not allowing php files to run, to run a download on those scripts and have the visitor download each php/html except index.php file, OR actually just forbid the execution. So here are both options. To have index.php execute on the server, and all other php and html files download to client browser: <FilesMatch "\b(?!.*index\.php$)(.+)(?i)\.(htm|html|php|php4|php5)$"> SetHandler application/octet-stream </FilesMatch> Code (markup): To have index.php execute, and all other php files return "403 Forbidden": <FilesMatch "(?i)\.(php|php4|php5)$"> Order Allow,Deny Deny from all </FilesMatch> <FilesMatch "index\.php$"> Order Allow,Deny Allow from all </FilesMatch> Code (markup): Some further testing should be applied to both snippets... but I believe it should be working fine. Cheers!