Using .htaccess to make all .html pages to run as .php files?

前端 未结 16 1473
忘了有多久
忘了有多久 2020-11-22 00:41

I need to run all of my .html files as .php files and I don\'t have time to change all of the links before our presentation tomorrow. Is there any way to \"hack\" this with

相关标签:
16条回答
  • 2020-11-22 01:27

    Using @Marc-François approach Firefox prompted me to download the html file

    Finally the following is working for me (using both):

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

    0 讨论(0)
  • 2020-11-22 01:34

    I think this is the best way to run php script on html and htm pages:

    AddType application/x-httpd-php5 .html .htm
    
    0 讨论(0)
  • 2020-11-22 01:34

    Running .html files as php stopped working all of a sudden in my .htaccess file.

    Godaddy support had me change it to:

    AddHandler application/x-httpd-lsphp .html
    
    0 讨论(0)
  • 2020-11-22 01:35

    On Dreamhost Servers you can refer to this page that at time of writing indicates you may use the following for php 7.2 with FastCGI:

    AddHandler fcgid-script .html
    FcgidWrapper "/dh/cgi-system/php72.cgi" .html
    

    Or if you are using php5 cgi (not FastCGI):

    AddHandler php5-cgi .html
    
    0 讨论(0)
  • 2020-11-22 01:39

    For anyone out there still having trouble,

    try this (my hosting was from Godaddy and this is the only thing that worked for me among all the answers out there.

    AddHandler x-httpd-php5-cgi .html
    
    0 讨论(0)
  • 2020-11-22 01:42

    I'm using PHP7.1 running in my Raspberry Pi 3.

    In the file /etc/apache2/mods-enabled/php7.1.conf I added at the end:

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