5

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..

Vaibhav Gupta
  • 1,592
  • 1
  • 13
  • 23
  • Probably the php version in your localhost is not 5? – Andreas Wong Dec 04 '10 at 07:30
  • no... I am using PHP 5.3.1 in localhost... – Vaibhav Gupta Dec 04 '10 at 07:31
  • @Vaibhav Gupta - What is the supported mime in `mime.types` ? – ajreal Dec 04 '10 at 08:03
  • @Vaibhav Gupta - Inside apache directory, there is a file with name mime.types. You can open the file and check both application/x-httpd-php5 & application/x-httpd-php are specified. If only application/x-httpd-php is specified, it explain application/x-httpd-php5 does not work – ajreal Dec 04 '10 at 10:48
  • @ajreal - i have checked the mime.types file and both application/x-httpd-php5 & application/x-httpd-php are not specified... :( – Vaibhav Gupta Dec 04 '10 at 10:58
  • Make sure you are using correct module http://stackoverflow.com/questions/9369781/htaccess-rule-to-parse-php-in-html-files-not-working – leon_developer Aug 30 '14 at 15:48

1 Answers1

3

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.

mspir
  • 1,664
  • 2
  • 21
  • 34