Process HTML files like PHP

后端 未结 4 1949
清酒与你
清酒与你 2020-11-29 11:17

I\'ve been trying to get .html files to process like .PHP files, using the .htaccess file. I\'ve used the following, both of which don\'t work and trying to access the test

相关标签:
4条回答
  • 2020-11-29 11:56

    You need to add

    AddHandler application/x-httpd-php .html .htm
    
    0 讨论(0)
  • 2020-11-29 12:08

    You need to know whetheryou are using php-fpm instead of php module. If you are using php-fpm, then you have to do two things:

    1) in httpd.conf add the lines:

    <FilesMatch \.(html)$>
        SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost"
    </FilesMatch>
    

    2) in php-fpm.d/www.conf make sure you have the line

     security.limit_extensions =
    

    This will work. Maybe there are better settings, I don't know. I do know that if you have php-fpm, none of the answers involving AddHandler, AddType are going to work.

    0 讨论(0)
  • 2020-11-29 12:12

    Try this:

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

    or

    AddHandler x-httpd-php .html .htm
    

    or

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

    or

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

    Edit: For 1&1 server:

    AddType x-mapp-php5 .html .htm
    

    One of these should work

    0 讨论(0)
  • 2020-11-29 12:16

    You can try the code below also.

    AddHandler x-httpd-php .html .htm
    

    OR

    AddType application/x-httpd-php .html .htm
    
    0 讨论(0)
提交回复
热议问题