Is it possible to add headers (defined in a .htaccess
file) to a response generated by PHP?
I have the following .htaccess
file in my that should add a Header TestHeader
to each response delivered by my Apache Webserver:
#<IfModule mod_headers.c>
# Header unset X-Powered-By
Header add TestHeader "It works."
#</IfModule>
I also have three additional files in that folder:
html.html
<html>content</html>
1.php
<?php echo "<html>content php</html>";
2.php
<?php header("TestHeader: Sent from PHP."); echo "<html>content php</html>";
- Requesting
html.html
returns the headerTestHeader: "It works."
- Requesting
1.php
does not return headerTestHeader
- Requesting
2.php
returns the headerTestHeader: "Sent from PHP."
- Requesting
Is it somehow possible to manipulate the response header from PHP output using .htaccess
directives?
EDIT: PHP runs as FastCGI
on the server.