News

Article updates

How to use WP Hide PRO on older Apache

The WordPress WP Hide PRO plugin provide advanced features and functionality for keeping a site 100% secure, from being hacked and exploited. Security is an important factor which every site administrator put a lot of effort to improve, the WP Hide plugin is a must have code for everyone who need to secure their digital assets.

At code level, the plugin take advantage of latest technologies which a server can provide, to implement the additional security benefits. Maintaining the server software up to date is mandatory to ensure best results and compatibility is provided along existing code.

Keeping everything coeval at the server level might take time, sometime compatibility between components can be a real pain to achieve. For such reason (or anything else) on some servers older version of Apache can found. While WP Hide PRO can work and deliver the best results with Apache 2.3 and up, it can still work with no issues with old versions, with the help of a small php code patch. Mainly the issue is caused by a missing flag END https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_end which has been implemented starting Apache 2.3

The following code should be placed within a file e.g. wp-hide-apach-patch.php inside wp-content/mu-plugins/ folder.


<?php
    /**
    * Alternative method whcih use L flag instead END which not being available for Apache older than 2.3
    * 
    */
    add_filter('wp-hide/mod_rewrite_rules', 'wp_hide__mod_rewrite_rules', 999, 2);
    function wp_hide__mod_rewrite_rules( $rules, $server_software )
        {
            
            if  ( $server_software !=   'apache' )
                return $rules;
                
            
            $rules  =   '#Pass-through if another rewrite rule has been previouslly applied'    .
                        "\n"    .   'RewriteCond %{ENV:REDIRECT_STATUS} 200'    .
                        "\n"    .   'RewriteRule ^ - [L]' . 
                        "\n\n"  .   $rules;
            
            //replace all END flags with L
            $rules  =   str_replace( array('[END', 'END]', ',END,'), array('[L', 'L]', ',L,'), $rules );
            
            return $rules;
            
        }
?>

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
Scroll to top