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 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!