• # BEGIN Serve Static Cache
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_COOKIE} !(^|;\s*)wordpress_logged_in_.*$ [NC]
    RewriteCond %{REQUEST_URI} !^/(elementor|vc_row|fl_builder|fl-theme-builder) [NC]
    RewriteCond %{REQUEST_URI} !^/wp-admin/ [NC]
    RewriteCond %{REQUEST_METHOD} GET
    RewriteCond %{QUERY_STRING} ^$ [NC]
    RewriteCond /home/user/public_html/custom/serve-static-cache/$1/index.html -f
    RewriteRule ^(.*)$ /custom/serve-static-cache/$1/index.html [L]
    # END Serve Static Cache

    I’ve been using the standard HTACCESS settings and was under the impression everything was working properly. Today I enabled the fallback method (php) and now it’s really working! I went as far as making a manual edit to one of the cached index.html files to verify both modes and the .htaccess rules are not working at all.

    I tried moving the rules to the top and the bottom of the .htaccess to see if they were being overridden, no change. Only the PHP version is working.

    I also tried wrapping the rules in <IfModule mod_rewrite.c>…</IfModule> without success.

    Any help would be great. Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Rajin Sharwar

    (@rajinsharwar)

    Hi @tmcguire, sorry to hear that. Confirming this is a Apache Server right? Secondly, I would suggest you to remove the rules you added manually. Then deactivate the Serve Static plugin, and reactivate it. If got appropriate access, the plugin should auto-add the required .htaccess code.

    If this is still not working, feel free to ping and share with me via the support form found under the Serve Static > Support, your site details and I can take a look what’s happening.

    Thread Starter T.McGuire

    (@tmcguire)

    Yes — this is Apache. I have removed the Serve Static .htaccess rules, and deactivated/reactivated the plugin. Upon reactivation, .htaccess rules reappear. Cleared the cache, regenerated a full cache and verified the cache files exist on the server.

    Disabled the PHP fallback method and the plugin is not serving the cached file. If I turn ON the PHP fallback, it serves the cached file. Tested on 2 different web sites in different homdir’s

    There are no errors in the logs and mod_security is not being triggered. There are no other caching plugins installed.

    Tested on 2 seperate websites. Same issue is on both.

    Thread Starter T.McGuire

    (@tmcguire)

    I think I just fixed it.

    I replaced your function with my own and now it’s working. There were mixed paty types in yoru rewrite contidions and rules in Activate.php. It was creating double folder paths.

    public function rules(){
        $begin = '# BEGIN Serve Static Cache';
        $end = '# END Serve Static Cache';
    
        $site_url = get_site_url();
    
        // Parse the URL
        $parsed_url = wp_parse_url($site_url);
    
        // Check if there is a path component in the URL
        if(isset($parsed_url['path']) && !empty($parsed_url['path'])) {
            // Get the folder name from the path
            $folders = explode('/', trim($parsed_url['path'], '/'));
            $folder_name = $folders[0]; // Assuming the folder is the first component of the path
    
            // Now $folder_name contains the name of the subdirectory (if it exists)
            $folder = $folder_name;
        }
    
        if ( ! isset( $folder ) ) { //If not on sub-folder, then do nothing
            $folder = '';
        } else {
            $folder = '/' . $folder;
        }
    
        if ( ! defined( 'WP_CONTENT_FOLDERNAME' ) ){
            define( 'WP_CONTENT_FOLDERNAME', 'wp-content' );
        }
    • This reply was modified 5 months, 3 weeks ago by T.McGuire.
Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.