Skip to content

Instantly share code, notes, and snippets.

@ryanshoover
Created February 4, 2019 20:02
Show Gist options
  • Save ryanshoover/470579cea6a2a2ca94e8f548e9af7535 to your computer and use it in GitHub Desktop.
Save ryanshoover/470579cea6a2a2ca94e8f548e9af7535 to your computer and use it in GitHub Desktop.
WP Plugin Stop htaccess rewrites
<?php
/**
* Stop htaccess rewrites
*
* @package wpengine-stop-htaccess-rewrites
* @author wpengine
* @license Proprietary
*
* @wordpress-muplugin
* Plugin Name: Stop htaccess rewrites
* Plugin URI: https://wpengine.com
* Description: Stops Rewrite Flush from changing the htaccess file on proxy passed sites.
* Version: 0.1.0
* Author: wpengine
* Author URI: https://wpengine.com
* Text Domain: wpengine-stop-htaccess-rewrites
* License: Proprietary
*/
namespace WPEngine\StopHardRewrite;
add_action(
'plugins_loaded',
function() {
// Get the PATH from the site url.
$path = wp_parse_url( get_option( 'siteurl' ), PHP_URL_PATH );
// If we have a path, then this is a proxy pass. Stop hard rewrites.
if ( ! empty( $path ) && '/' !== $path ) {
add_filter( 'flush_rewrite_rules_hard', '__return_false' );
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment