html not parsing as php in wamp

喜夏-厌秋 提交于 2019-12-05 01:05:10

问题


I am using this snippet in my .htaccess file to parse html as php:

<FilesMatch "\.(html|htm|txt)$">
 SetHandler application/x-httpd-php5
</FilesMatch>

this is working fine in my website(online) but not in my localhost (using WAMP latest version).. but if I change the above code to:

<FilesMatch "\.(html|htm|txt)$">
 SetHandler application/x-httpd-php
</FilesMatch>

then, this is working fine in my localhost but not in my website.. I have to add/remove the 5 in SetHandler application/x-httpd-php to work in either one side.

Please, help me..


回答1:


You can edit your local httpd.conf file, and add the mime modules you need:

<IfModule mime_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php .html
AddType application/x-httpd-php .htm
AddType application/x-httpd-php .txt
</IfModule>

This should work for your local host. If you can't configure your server this way, and since your .htaccess works there, use the .htaccess config for your server only.



来源:https://stackoverflow.com/questions/4352483/html-not-parsing-as-php-in-wamp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!