1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Include a file globally with Auto Prepend File
This guide explains how to specify a file that will be loaded before the desired page or at the beginning of each PHP script executed on your server, included as if it had been called with the require()
function, but more globally using the PHP directive auto_prepend_file
.
Preamble
- For example, to declare the headers of a website, you can create a
headers.php
file that contains PHPheader()
functions and that is prepended at the beginning of each PHP file…- … via a
.user.ini
file (specific to a folder), - … or via the site configuration in the Manager (global) as explained below.
- … via a
Include a file globally from the Manager
To access the website management:
- Click here to access the management of your product on the Infomaniak Manager (need help?).
- Click directly on the name assigned to the product concerned:
- Click on Manage under Advanced settings:
- Click on the PHP / Apache tab.
- Complete the relevant line by entering the path of the file to include.
- Click the button to save:
After defining this directive, all PHP pages on your server will automatically include the specified file before executing their own code.
The headers defined in a .htaccess
file are only valid for non-PHP (i.e., static) content.
Infomaniak uses php-fpm
which receives the different headers via apache fast_cgi
. In the RFC of cgi_www the header Strict-Transport-Security
is not part of the headers passed via CGI and the Apache documentation confirms this. See this other RFC.
⚠️ For additional help contact a partner or launch a free tender — also discover the role of the host.