see this

and this

<IfModule !mod_php5.c>
    <FilesMatch "\.php$">
        Order allow,deny
        Deny from all
        Allow from none
    </FilesMatch>
</IfModule>

now i cant know mod_php5.c name becuase iam is not the server owner me is just have small host now is there any other way to do that this man i want deny access php file when the php is no longer here

link|improve this question
Can you give some more details? It is hard to understand exactly what you want. – Joshua Nurczyk Jan 8 '10 at 13:23
Checking for mod_php5 is very unreliable also because PHP sometimes runs as a normal CGI process... oh, and there are other httpds besides Apache, too. – grawity Jan 8 '10 at 16:41
It seems to me that the poster wants to disable access to .php files, but only when PHP is NOT enabled. Possibly in order to avoid outputting source code? – Martijn Heemels Apr 20 '10 at 15:29
feedback

2 Answers

Put all files in another folder outside the server root, set a separate file configuring the path to that second folder; after that leave in your web root php files with the same name and include the real files on the fly.

An example for index.php:

<?php
    require '../mysite_config.inc.php';
    require INCDIR . 'index.php';
?>

where mysite_config.inc.php contains:

<?php
    define('INCDIR', '../the_real_folder/');
?>
link|improve this answer
+1 Any php files containing sensitive data (eg. MySQL Connection strings) should be in an include file in a directory that is outside the website root. Or at least in a directory that you deny access to regardless of whether PHP is working or not. You don't have to deny access to absolutely every php script, just the sensitive ones. – kaerast Apr 20 '10 at 14:26
feedback

If you want to deny access to all PHP files, you could just use mod_rewrite:

RewriteEngine On
RewriteRule *.php accessdenied.html

And have a HTML file called "accessdenied.html" which displays an error, or replace "accessdenied.html" above with a link to the page you want the user to be redirected to.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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