How to set up a W3TC mirror CDN for WP multisite with domain mapping

WordPress Multisite with the domain mapping plugin is a good way to run multiple wordpress sites. It means you don’t have to worry about keeping WordPress and plugins up to date for each individual site.

The W3 Total Cache plugin is one of the most popular wordpress plugins for speeding up wordpess websites. One of the things it offers is serving static content from a CDN (Content Delivery Network). You don’t have to use a real CDN, but can instead a generic mirror CDN.

A generic mirror CDN doesn’t have all the benefits of a real CDN. However, because you use a different domain (or subdomain) for the CDN address, it does solve the problem of cookies being sent for static content requests. And unlike a real CDN, you don’t need to pay anything extra for it.

Continue reading

Posted on by xoogu, last updated

.htaccess rule to prompt file download

Here’s a quick .htaccess trick you can use to make a user’s browser prompt them to download an image rather than the image just opening in the browser.

RewriteEngine On
RewriteCond %{QUERY_STRING} =download
RewriteRule ([^/]*)$ - [L,E=download:$1]
Header onsuccess set Content-disposition "attachment; filename=%{download}e" env=download

What this does is that any links to images (or any other file) will be handled normally, but if you add ‘?download’ to the end of your link, the user will be prompted to download the file instead, e.g.

Normal link <a href="/filepath/some-image.jpg" >Link</a>
Download link <a href="/filepath/some-image.jpg?download" >Link</a>

Continue reading

Posted on by xoogu, last updated