Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

see this

and this

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

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

share|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

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:

    require '../';
    require INCDIR . 'index.php';

where contains:

    define('INCDIR', '../the_real_folder/');
share|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

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.

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.