Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: CDN Rewrite
- Plugin URI: http://blog.andrewshell.org/cdnrewrite
- Description: Rewrite urls on page if behind a CDN
- Author: Andrew Shell
- Version: 1.0.0
- Author URI: http://blog.andrewshell.org/
- */
- if (0 == strcmp($_SERVER['HTTP_USER_AGENT'], 'Amazon CloudFront')) {
- $now = time();
- $expires = strtotime('+1 hour', $now);
- header("Expires: " . gmdate(DATE_RSS,$expires) . "\n");
- add_filter( 'home_url', 'cdnrewrite_url', 100, 4 );
- add_filter( 'site_url', 'cdnrewrite_url', 100, 4 );
- }
- function cdnrewrite_url( $url, $path, $orig_scheme, $blog_id )
- {
- return str_replace('blog.andrewshell.org', 'd11b8ym2xu437t.cloudfront.net', $url);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement