Skip to content

Instantly share code, notes, and snippets.

@hideokamoto
Created December 1, 2015 16:21
Show Gist options
  • Save hideokamoto/a693ab7341cabe1a9452 to your computer and use it in GitHub Desktop.
Save hideokamoto/a693ab7341cabe1a9452 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: CloudFront Host Fix
Plugin URI:
Description: CloudFront & Nginx Reverse Proxy Cache fix.
Version: 0.1
Author:
Author URI:
*/
add_action('redirect_canonical', 'change_requested_url');
function change_requested_url($redirect_url, $requested_url) {
$redirect_url = is_ssl() ? 'https://' : 'http://';
$redirect_url .= $_SERVER['HTTP_HOST'];
$redirect_url .= $_SERVER['REQUEST_URI'];
return $redirect_url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment