开发者

Parse PHP in .html files with IIS and FastCGI

I have a big site with lots of .html files, and I want to start using PHP in my pages, but I don't want to change the links to .php . I read on Apache s开发者_C百科ervers you can add a rule to the .htaccess file that will allow PHP parsing in plain .html files. Is this possible in IIS?


Absolutely. Assuming you're using IIS7, you simply change the request path in "Handler Mappings" to *.html (to handle all html files).

Note that you'll get a big performance hit though. It's much quicker to serve static content, so if you have lots of html pages every single one of them will start being parsed by PHP. It would be preferable to switch pages to .php as needed, but I understand that it would be tricky to fix all the backlinks.

More information about setting it up is available here.


Be aware that when changing handler mappings you'll also want to make sure it is still sending the correct MIME types. I just implemented the solution Hamish linked to, but all my CSS @import directives were failing, as they were to pure .css files which were now being served with PHP's standard text/html Content-type header.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜