Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AddType application/x-httpd-php .php is not rendering PHP

Tags:

php

apache

Adding this code:

AddType application/x-httpd-php .php after

...
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

to C:\Apache24\bin\httpd.conf downloads all PHP pages on my system rather than render it.

Before then, the PHP pages were parsed as raw text.

Help needed!

like image 365
Lapys Avatar asked Aug 19 '17 15:08

Lapys


1 Answers

There are two problems:

  1. application/x-httpd-php is not a MIME type, but rather a handler. That means your directive must be AddHandler instead of AddType

  2. application/x-httpd-php is not a valid handler. The handler must include the PHP version digits at the end of the string

Putting that altogether, assuming, say PHP version 7.2, what you want is

   ✅ AddHandler application/x-httpd-php72 .php instead of
   🚫 AddType application/x-httpd-php .php

like image 116
Lucas Avatar answered Sep 28 '22 05:09

Lucas