Webdav and php


#1

Using WebDAV in Windows Explorer works great, but when trying to copy a *.php file from the DAV folder on the website to my local system, the *.php file is parsed by the dreamhost server.
So I only get the resulting page instead of the *.php source.
Any ideas in solving this?


#2

[quote]
I’m getting PHP output rather than the source

This is caused by the simple fact that a GET is always going to run the script. There is no way to distinguish a “GET for the result” and a "GET for authoring."
Note: this problem applies to any server-side scripting solution. It is not specific to PHP. For demonstrations sake, I will use PHP as an example.

PHP and mod_dav will also conflict when they each attempt to handle the different HTTP request methods. This is caused by the simple fact that both modules are configured for the same location or directory, and are competing for acting as the content handler.

There are several ways to fix this. They all solve the problem by providing a separate URL to access the PHP source. In one scenario, you can provide a simple “source” URL:

[color=#0000CC]Alias /phparea /home/gstein/php_files
Alias /php-source /home/gstein/php_files
<Location /php-source>
DAV On
ForceType text/plain
[/color]

A different alternative is to present the source through another virtual server:

[color=#0000CC]<VirtualHost 12.34.56.78>
DocumentRoot /home/gstein/php_files

<VirtualHost 12.34.56.78:81>
DocumentRoot /home/gstein/php_files
DAV On
ForceType text/plain
[/color]

There are probably a few, similar ways to accomplish the same kind of setup. I have used the first form (a secondary URL space) successfully, but have not tried the second virtual host. Other people have reported success with it, however.

In each of these ways to fix the problem, we are taking advantage of the fact that there are different URL namespaces that map to the same, underlying filesystem space. By attaching different processing to the URL spaces, we can create different behaviors during the translation to the filesystem space.

Finally, I believe that it may be possible to ensure that mod_dav occurs later in the AddModule directives, thus making mod_dav be the content handler for methods besides GET. If PHP is later in the list, then it will end up handling all methods. This trickery does not solve the authoring problem, however.[/quote]
Source : http://www.webdav.org/mod_dav/install.html

httpd.conf setup, maybe DH has already something in the works as specified above.


#3

Thanks DaRkMaN, sounds like a straightforward solution.
I’ll ask Dreamhost, fingers crossed!


#4

np :slight_smile:
/me crosses fingers 2


#5

Cool, Dreamhost implemented it and it works great! I now have an alias /php-source pointing to my WebDAV folders, that handles all files like they are text sources. Thanks again.


#6

Great, glad it worked out, a big thumbs up for DH :slight_smile:
Should be pretty straightforward to implement this functionality through the panel, a minor but still nice feature to have.