• Resolved tdechangy

    (@tdechangy)


    Hi,

    I see these lines added to the htaccess rules

    # BEGIN W3TC Page Cache core
    <IfModule mod_rewrite.c>
        RewriteCond %{HTTPS} =on
        RewriteRule .* - [E=W3TC_SSL:_ssl]
        RewriteCond %{SERVER_PORT} =443
        RewriteRule .* - [E=W3TC_SSL:_ssl]
        RewriteCond %{HTTP:X-Forwarded-Proto} =https [NC]
        RewriteRule .* - [E=W3TC_SSL:_ssl]
        RewriteCond %{HTTP:Accept-Encoding} gzip
        RewriteRule .* - [E=W3TC_ENC:_gzip]
        RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
        RewriteRule .* - [E=W3TC_PREVIEW:_preview]
        RewriteCond %{REQUEST_METHOD} !=POST
        RewriteCond %{QUERY_STRING} =""
        RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
        RewriteCond %{REQUEST_URI} \/$
        RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
        RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
    </IfModule>
    # END W3TC Page Cache core

    But when testing those on https://htaccess.madewithlove.be/ it displays more errors than valid rules. How should I interpret this ?
    Are they too old rules to be removed from your plugin totally, or does it only not meet my server setup ?

    What would be the incidence of removing those rules ?

    NB: all I want is making my htaccess file as light as possible.

    Regards

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @tdechangy

    Thank you for your iqnuiry and I am happy to assist you with this.
    Those rules are, as it says in the description Page Cache core rewrite rules and conditions.
    The tool you mentioned for checking the .htaccess may not like them but those rues are needed for Page Caching. Removing those rules would have no effect since every time you visit the dashboard and Page Cache is enabled, they would be added again to .htaccess.
    To confirm, you should not remove those rules and those rules are needed for Page Caching.
    Thanks!

    Thread Starter tdechangy

    (@tdechangy)

    All right, this sound good.

    Do you eventually know a better tool to check or even enhance an htaccess file ?

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @tdechangy

    The testing tools cannot know which plugin you are using or which rules you applied yourself.
    The best thing that you can do is do it yourself.
    For example, this is the basic .htaccess that is containing only WP rules:

    # BEGIN WordPress
    
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    
    # END WordPress

    Everything else withing the .htaccess is being added either by a plugin like W3 Total Cache (rewrite rules, Browser Cache rules), or some other plugin like for instance short pixel for image optimization.
    So my advice is to check which plugins are adding the rules (like # BEGIN W3TC) and make sure you don’t have any rules that might conflict, like double compression or rewrite.
    Thanks!

    Thread Starter tdechangy

    (@tdechangy)

    This is exactly the base point, how to check eventual rewrites.
    htaccess rules are pretty complex, which I never learned. I only used snippets from here and there, which is why I would like to check it to avoid rewrites, deprecated rules etc.

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘invalid htaccess rules’ is closed to new replies.