skip to Main Content

The following makes the list of extensions capable of executing PHP:

AddType application/x-httpd-php5 .php .php5

How do I allow only one specific file to be able to run PHP?

The following does not work:

AddType application/x-httpd-php5 example.php9

2

Answers


  1. You should use rewrite rule in htaccess.

     RewriteRule ^example.php9/?$ exmaple.php
    
    Login or Signup to reply.
  2. You can not add filename to AddType directive. Only file extensions are allowed. To add php handler to a single file you can use this :

     RewriteEngine on
    
     RewriteRule ^thisfile.php$ - [H=application/x-httpd-php5]
    

    Or <filesMatch>

    <filesMatch "^thisfile.php$">
    AddType application/x-httpd-php5 .php
    </filesMatch>
    

    Reference :

    Mod-rewrite flags

    https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_h

    filesMatch

    https://httpd.apache.org/docs/2.4/mod/core.html#filesmatch

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search