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 "auto_prepend_file" directive.
⚠️ For additional assistance contact a partner or fill out a bid request — also read the host's role
For example, to declare the headers of a website, it is possible to create a headers.php file that contains PHP header() functions and is prepended at the beginning of each PHP file:
- via a .user.ini file (specific to a directory)
- or via the site configuration in the Manager (global) as explained below
Include a file globally from the Manager
To access the website management:
- log in to the Infomaniak Manager (manager.infomaniak.com) from a web browser like Brave or Edge
- click on the icon at the top right of the interface (or navigate using the left side menu, for example)
- choose Website (universe Web & Domain)
- click on the name of the relevant object in the displayed table
- click on the Advanced settings button
- under the Apache tab, enter the path of the file to include
- 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 content (i.e., static).
Infomaniak uses php-fpm which receives different headers via apache fast_cgi. In the CGI RFC, the "Strict-Transport-Security" header is not included in the headers passed via CGI, and the Apache documentation httpd.apache.org/docs/2.2/howto/cgi.html confirms this. Also, read https://www.ietf.org/rfc/rfc3875