0

I'm running a PHP website locally using WebMatrix. This site uses PHP within *.html files. By default, WebMatrix doesn't allow this. How do I configure WebMatrix so that the PHP runs?

(note that I'm answering my own question)

Marcus
  • 189
  • 2
  • 9

1 Answers1

2

You need to edit the file:

%USERPROFILE%\Documents\IISExpress\config\applicationhost.config

(For example, "C:\Users\Marcus\Documents\IISExpress\config\applicationhost.config")

You'll notice a line like this:

<add name="PHP53_via_FastCGI" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\iis express\PHP\v5.3\php-cgi.exe" resourceType="Either" />

You can add other file extensions by adding new lines:

<add name="PHP53_via_FastCGI_html" path="*.html" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\iis express\PHP\v5.3\php-cgi.exe" resourceType="Either" />
<add name="PHP53_via_FastCGI_htm" path="*.htm" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\iis express\PHP\v5.3\php-cgi.exe" resourceType="Either" />

It's important that you give each <add /> element a unique 'name' attribute.

Marcus
  • 189
  • 2
  • 9
  • (If anyone is reading this and has a better solution, please do tell! After a couple tries, I couldn't figure out a syntax that would let me do this all within a single element (e.g. "*.php,*.htm,*.html")) – Marcus Aug 05 '12 at 18:21
  • Ignore the italics in the last comment. I wanted actual asterisks on both sides of ".php," – Marcus Aug 05 '12 at 19:28