question

wahabraiz19-8630 avatar image
1 Vote"
wahabraiz19-8630 asked wahabraiz19-8630 edited

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

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-server-iis
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SamWu-MSFT avatar image
0 Votes"
SamWu-MSFT answered

Hi @wahabraiz19-8630

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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.