Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.