简体   繁体   中英

Parsing .html as PHP in .htaccess for Apache 2.4

I am hosting in a whm/cpanel server and two of my sites were having .htaccess files that would parse .html files to .php.

However, the server is upgraded to Apache 2.4 and PHP to 5.5.38.

Since then the .htaccess files are not parsing the .html as PHP. I contacted the server provider, they said that the syntax for 2.4 is different which they don't know.

I'm a novice. If someone please help me with the correct .htaccess codes and if there is any module to be installed or scripts to be added in the root level, please provide me the step by step guidance - as I will just forward those instructions to the server provider.

Thanks in advance...

I'm not aware of any changes to the AddType or AddHandler directives between 2.2 and 2.4 - it could be the case that your htaccess file simply isn't running (disabled via AllowOverride , etc), or that it contains some other directive that isn't compatible with the new versions.

The required directive should be something like:

AddType application/x-httpd-php .html .htm

or

AddHandler application/x-httpd-php .html .htm

depending on the configuration.

Assuming AllowOveride is such that SetHandler is allowed.. per http://httpd.apache.org/docs/current/mod/core.html#sethandler .htaccess should look like...

 <FilesMatch "\.html$">
  SetHandler application/x-httpd-php
</FilesMatch>

Check /etc/apache2/apache2.conf and /etc/apache2/conf.d where AllowOverride is typically set. Check out http://httpd.apache.org/docs/current/mod/core.html#allowoverride for the syntax and list of allowable methods.

新语法为:

AddHandler "proxy:unix:/usr/local/php56/sockets/[username].sock|fcgi://localhost" .html .htm .inc

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