Report this

What is the reason for this report?

How can i access a php function in a file with file name "secret.info" ? sethandler,add handler are is not working

Posted on March 14, 2018

<FilesMatch> SetHandler application/x-httpd-php </FilesMatch> AddHandler application/x-httpd-php .php

#content of secret.info <?php phpinfo() ?>



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

If you want all .info files to be parsed as PHP, add this to your .htaccess file:

AddHandler application/x-httpd-php .php .info

To enable the execution of PHP code within a file with an unconventional extension (like .info) on an Apache server, you generally need to tell Apache to process such files as PHP. This is commonly achieved by modifying your Apache configuration to use the AddHandler or SetHandler directive to treat the custom file extension as PHP.

To enable the execution of PHP code within a file with an unconventional extension (like .info) on an Apache server, you generally need to tell Apache to process such files as PHP. This is commonly achieved by modifying your Apache configuration to use the AddHandler or SetHandler directive to treat the custom file extension as PHP.

It seems like you’ve encountered issues with using these directives. Here’s how you can troubleshoot and correctly set up Apache to process files with the .info extension as PHP:

Step 1: Confirm PHP Module is Enabled

First, ensure that the PHP module is correctly loaded in your Apache configuration. You can check this by looking for a line like LoadModule php7_module modules/libphp7.so in your Apache configuration files (the exact path and module name might vary depending on your PHP version).

Step 2: Modify .htaccess or Apache Configuration

You can use either the .htaccess file in the directory where your secret.info file resides, or modify the global or virtual host configuration files directly (e.g., httpd.conf or 000-default.conf).

Here’s how to do it:

Using .htaccess

  1. Create or edit the .htaccess file in the same directory as your secret.info file.

  2. Add the following configuration:

<FilesMatch "\.info$">
    SetHandler application/x-httpd-php
</FilesMatch>
  • This tells Apache to treat all files ending in .info as PHP files. - Make sure that you are allowed to use .htaccess in this directory. The AllowOverride All directive must be set in the main configuration file for Apache to read .htaccess files.

Modifying Apache Configuration File

  1. Open your Apache configuration file (httpd.conf, apache2.conf, or a virtual host configuration file).

  2. Add the FilesMatch directive inside the appropriate <Directory> block or at a global level if you want this behavior server-wide:

<FilesMatch "\.info$">
    SetHandler application/x-httpd-php
</FilesMatch>

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.