iCal Publishing Problems with WordPress
Update: WordPress 2.1 does not work with this. If you are using version 2.1+ try out my WebDAV Publish Enabler plugin.
If you use WordPress and publish your iCal calendar to your website then you may have run into the problem where iCal refuses to publish saying you cannot write to the directory. This is happening because WordPress Permalinks create a .htaccess file on your web site which can disable WebDAV publishing in some setups.
A quick fix is to simply edit the .htaccess file and add the highlighted line in the following part:
# BEGIN WordPress
RewriteEngine On
RewriteBase /path/to/wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(dav|ical|_ical)
RewriteRule . /index.php [L]
# END WordPress
The rule above contains the most likely locations of the calendar (dav|ical|_ical). If you are publishing to a different directory make sure to update the rule.
While this works, it’s only a temporary fix. If WordPress has the ability to write to your .htaccess file your modifications will be overwritten next time you add or edit a post. If you made it this far, published once, and then iCal stopped publishing again, this is probably why.
The more permanent fix is to edit the wp-includes/classes.php file itself. Open it up and do a search for “RewriteRule” (there are two locations at lines 1397 and 1418) and add the highlighted line below:
$rules .= "RewriteCond %{REQUEST_FILENAME} !-f\\n" .
"RewriteCond %{REQUEST_FILENAME} !-d\\n" .
"RewriteCond %{REQUEST_URI} !^/(dav|ical|_ical)\\n" .
"RewriteRule . {$home_root}{$this->index} [L]\\n";
Each time you make a post WordPress will now re-write the correct rules allowing you to publish your calendar successfully.
