Created
February 4, 2019 20:02
-
-
Save ryanshoover/470579cea6a2a2ca94e8f548e9af7535 to your computer and use it in GitHub Desktop.
WP Plugin Stop htaccess rewrites
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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