dongren9739 2015-06-09 13:11
浏览 120
已采纳

html文件解析为php但显示为html

I have a website which has a bunch of simple HTML pages. There is a menu in the page and of course the html is repeated across all the pages. I want to be able to put the menu in a php file and then have it as an include in all html files.

I thought I could do this with .htaccess by getting all html files parsed as php. However I'm having real problems getting it to parse. I've been tons of google links and have tried a bunch of stuff but none of it seems to work any ideas:

stuff I've tried:

            # Use PHP5.4 as default

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



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

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

Not all at once but line by line. None of it worked! The server uses fast cgi so I think actually only the addhandler stuff is needed and it uses 5.4.4

thanks

  • 写回答

1条回答 默认 最新

  • drob50257447 2015-06-10 08:28
    关注

    My answer in the comment (which I shouldn't have done) had the linebreak removed.

    Some hosts (including the one I use for their shared servers) have Linux configured differently. You might want to speak with them or check their support documentation, they may have answered it for you.

    For my host, this is the correct pair of commands to have PHP execute within files that have a .html extension.

    AddHandler cgi-script .html 
    SetEnv PHP_EXTENSION .html
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类