Handy WebDAV Hint: GET + PHP = Bad

I have a local server where the document path’s available published as a WebDAV folder. We usually don’t put PHP scripts in that folder. But we added one: a PHP utility script.

When I tried opening that script in that folder, I got the page’s HTML contents without the PHP. What gives?

WebDAV guru Jim Whitehead explains: since WebDAV uses HTTP GET to fetch a file, the web server will dutifully execute the PHP as it sends it.

Arrgh! Self.isClueless == true.

Solutions:

  • Don’t put PHP files in WebDAV shares.
  • If you do, don’t edit them. PUT a new copy when you make changes.
  • Using some sort of alias and set-handler-fu you could probably set up an alternate path to the share which doesn’t execute PHP.
  • Scott Reynen adds: opening the file as .phps if you’ve enabled it in your Apache configuration.

More like this: .