Lapys
Lapys

Reputation: 946

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

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!

Upvotes: 7

Views: 28059

Answers (2)

rm_beginners
rm_beginners

Reputation: 159

add this at the bottom of your httpd.conf make sure you have php{version}apache{version}.dll in line 3 and directory of  your php.

AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
LoadModule php7_module "c:/php7/php7apache2_4.dll"
PHPIniDir "c:/php7"

you can visit this link

Upvotes: -1

Lucas
Lucas

Reputation: 541

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

Upvotes: 10

Related Questions