Johnny5
Johnny5

Reputation: 6862

Adding an http header site wide in php

I'm maintaining a web site for a non-profit organisation. I'm not the one who designed this web site, and I don't know the person who did it.

That said, I have an issue with IE9. I will eventually try to correct it, but meanhile just adding the X-UA-Compatible header so IE9 turns to IE8 mode would work just fine.

In an asp.net web site, I would add it in the web.config with the <customHeaders> element (with IIS7).

Is there's a way to send this header for all file in a php web site, without editing all files?

Upvotes: 1

Views: 537

Answers (3)

Liam Bailey
Liam Bailey

Reputation: 5905

Apache MOD_HEADERS, add the following to your root .htaccess file

<FilesMatch "\.(php|cgi|pl|htm)$">
    Header set X-UA-Compatible IE=EmulateIE8
</FilesMatch>

This will set that header in the http header of all php, html, perl and cgi files, but I have had very bad experiences with the x-ua header, and found that it doesn't always work.

Upvotes: 3

Jeremy Clifton
Jeremy Clifton

Reputation: 533

If you're using some kind of templating engine, you could just add <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /> to the HEAD section of your template(s).

Otherwise, if you're including a single PHP file everywhere, you could add a header() call there (as long as it's before you output any content).

Upvotes: 0

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799062

auto_prepend_file and header(), or configure it in your web server with e.g. Header.

Upvotes: 1

Related Questions