How to prepend a PHP file to every page using web.config?

wahabraiz19 6 Reputation points
2021-06-10T19:37:59.327+00:00

I'm moving from a Linux VPS to a Microsoft Server. With my Linux OS, I was using Apache and could utilize .htaccess

In that file, I had this configuration:

php_value auto_prepend_file "/inetpub/htdocs/app/tpl/includes/config/config.php"

I then ran into the painful realization that .htaccess does not work with IIS, but only Apache. I now know that IIS uses web.config, but I'm sure what would be the equivalent of this in web.config.

I simply want to append a file to every single PHP page. The website doesn't work without having the config appended, as it contains routes to essential methods.

Windows development Internet Information Services
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Sam Wu-MSFT 7,561 Reputation points Microsoft External Staff
    2021-06-11T01:44:52.783+00:00

    Hi @wahabraiz19

    I think the best way is translate .htaccess content to IIS web.config, here a link about the use of the .htaccess file by PHP applications, and shows how to use the Web.config file for these same functions in IIS.

    translate-htaccess-content-to-iis-webconfig.


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.