: Server Side Includes that work in HTML and PHP with IIS 7 on Windows Server 2008 We currently have SSI set up to work in our HTML pages as follows <!--#INCLUDE file="/includes/header.inc"-->
We currently have SSI set up to work in our HTML pages as follows
<!--#INCLUDE file="/includes/header.inc"-->
We also use PHP on our server, and are trying to avoid creating two separate templates for PHP and HTML to include the same file. I know that in PHP I could include the file with the following command.
include 'header.inc';
This won't work in an HTML page, so is it possible to configure IIS 7 to have the #include directive work in both HTML and PHP pages? Is there a better way to do this period?
More posts by @Angie530
3 Comments
Sorted by latest first Latest Oldest Best
I think your instinct is right Blake, avoid adding .html/.htm to the PHP Engine if not absolutely necessary. PHP documentation slightly touches on the fact this could have a performance impact, but doesn't get into a lot of detail... in an article talking about hiding PHP from attackers/visitors.
See PHP Documentation: Hiding PHP
Your question, based on the subject line of this thread is deduced as, [Are there] includes that work in HTML and PHP in IIS 7 on Windows Server 2008 [?].
If you already have SSI enabled on IIS, then doesn't this already work in PHP as regular html, the way you have been doing it? Or are you looking for yet a 3rd include option that isn't SSI module or PHP engine/include function that works in both HTML and PHP code? If SSI does what you want, and you already have that loaded on your Windows server and have dedicated time and resources developing and securing it, AND it works with PHP, why look for another option? I don't mean this to be confrontational, just trying to learn a little bit more about the problem you are trying to solve.
Otherwise this works just the same:
.html Files
<!--#INCLUDE file="/includes/header.inc"-->
.php Files
<?php
echo "<!--#INCLUDE file="/includes/header.inc"-->n";
?>
Check these links: tech.mikeal.com/blog1.php/server-side-includes-for-html-in-iis7 http://www.iis.net/configreference/system.webserver/serversideinclude
Hope that could help.
This won't work in an HTML page, so is it possible to configure IIS 7 to have the #include directive work in both HTML and PHP pages? Is there a better way to do this period?
Something that might simplify things for you overall would be to configure IIS to use PHP code inside .html files instead of .php files. Then you'll be able to use PHP code directly in your HTML pages, and can use either the #include directive or PHP's include.
To do this in IIS 7, follow the steps covered here: Configure IIS to Handle PHP Requests, but change: Request path: *.php to -> Request path: *.html
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.