My understanding is:
AddHandler
- for serverAddType
- for client (browser)
AddType application/x-httpd-php4 .php4
AddHandler application/x-httpd-php4 .php4
But why do we need to add both? Is both needed in case of PHP? Is AddType
needed for PHP?
In your case it is just coincidence that the content type is equal to the name of the handler - given that there actually is a handler named
application/x-httpd-php4
. Otherwise it's just plain wrong.As has been said:
AddType
is used to associate file extension with a MIME-type (and therefore to changecontent-type
HTTP response header)AddHandler
/SetHandler
are used to bind file extension to a server side handler (like PHP).It seems like using
AddType
to bind PHP handler is an obsolete way that used beforeAddHandler
/SetHandler
was introduced in Apache 1.1.0.A little bit of history that I could find
There were no
AddHandler
/SetHandler
in Apache 1.0.xhttps://svn.apache.org/repos/asf/httpd/httpd/tags/1.3/apache_1_0_0/src/modules/standard/mod_mime.c contains:
April 1996
PHP/FI (PHP 2.0) introduced the Apache module version of PHP. The official Apache release at that time was 1.0.5.
README from https://museum.php.net/php2/php-1.99s.tar.gz contains:
src/mod_php.c from https://museum.php.net/php2/php-1.99s.tar.gz contains:
July 1996
AddHandler
/SetHandler
was introduced in Apache 1.1.0.https://svn.apache.org/repos/asf/httpd/httpd/tags/1.3/APACHE_1_1_0/src/CHANGES contains:
https://svn.apache.org/repos/asf/httpd/httpd/tags/1.3/APACHE_1_1_0/src/modules/standard/mod_mime.c contains:
December 2004
Rasmus Lerdorf said:
See also https://bugs.php.net/bug.php?id=36772.
June 2008
AddType
was replaced toSetHandler
/AddHandler
in PHP installation guide for Apache 2.x for security reasons.See also https://www.php.net/manual/en/install.unix.apache2.php#92797.
P.S.: but PHP installation guide for Apache 1.3.x still contains
AddType
(and it seems like obsolete way too).