简体   繁体   中英

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!

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM