Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoeyBurzynski/c2ec3338b5726d4d15bf1f822dd1ad01 to your computer and use it in GitHub Desktop.
Save JoeyBurzynski/c2ec3338b5726d4d15bf1f822dd1ad01 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