Fix WebDAV with PHP (files execute instead of GET)

Discussion in 'Developers' Forum' started by Steveorevo, Mar 1, 2010.

  1. Steveorevo

    Steveorevo Member

    There is bug that I've come across when running ISPConfig 2.2.35 where getting PHP files via WebDAV pulls down the executed script vs. the actual PHP content.

    To fix this problem you'll want to add directives via ISPConfig's Apache Directives (Optional) setting. I add the following that prevents PHP scripts from executing when downloading via WebDAV

    # Fix for PHP WebDAV
    <IfModule mod_dav.c>
    <Location /webdav>
    php_value engine off
    </Location>
    </IfModule>

    WebDAV is an excellent alternative to FTP because it can be secure (with optional SSL), HTTP(S) is optimized on most routers and networks, and its fast as hell. Its also supported on various OS's natively from OS X to Windows, and in 'professional' web IDEs like Dreamweaver (for designers) and phpED (for developers). With this fix I can develop faster using Dw and www.themedreamer.com developing WordPress themes.
     
  2. Steveorevo

    Steveorevo Member

    Additional fix for WordPress

    Hey Guys, I just wanted to followup as I've been having new problems crop up with WordPress. Alot of clients use WebDAV and WordPress with its 'Permalinks' feature. It does this by using .htaccess rules. I noticed that cPanel clients don't have a problem but ISPConfig does.

    Apparently cPanel creates a whole new sub-domain for webdav services webdav.yoursite.com (not a fan) with <Directory> directives of "AllowOverride None" to prevent even reading .htaccess.

    In ISPConfig this won't work, as adding <directory> directives would then break WordPress's permalinks, and the <Location> directives parse after reading .htaccess (again, which is how WordPress does permalinks).

    I found that to eliminate this problem, just add the line "Rewrite engine off" to the fix I had above. This will allow popular WordPress users with permalinks + WebDAV to work seamlessly. Sure beats having to login into WordPress's control panel, and then toggle permalinks on/off everytime one needs to upload a new file.

    So the new fix would look like this:

    # Fix for PHP WebDAV
    <IfModule mod_dav.c>
    <Location /webdav>
    php_value engine off
    Rewrite engine off
    </Location>


    Regards,
    Steve
     
    Last edited: Oct 26, 2010
  3. Steveorevo

    Steveorevo Member

    Nothing needs to be removed, rather, you should add the code above to the ISPConfig 2's "Apache Directives (Optional):" textbox on a site's definition.

    WebDAV is fast, but note that it does have different file permissions then FTP. Uploading a file via WebDAV may prevent that file from executing with read/write proper privileges (i.e. having wordpress install plugins, etc.). A faster alternative to FTP and WebDAV is to use SSH as file system. If you are on a mac, using MacFUSE is ideal.
     

Share This Page