• Resolved Gulshan Kumar

    (@thegulshankumar)


    Dear developer,

    When I had slash at the end of each permalink, before this plugin was working fine for me. It was serving in static mode.
    And, this header set was not available ‘X-Cache-Handle php’

    But, as I removed trailing slash from WordPress permalink settings and I set 301 redirection, after then the advanced Apache configuration code is not working. Still, I can see that in header response it is showing that Cache is handled via PHP (example)
    It is very strange for me.

    Below are the code, which I am using. Please have a look

    # BEGIN Cache Enabler
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    
    # set blog sub path
    SetEnvIf Request_URI "^(.*)$" SUB_PATH=/wp-content/cache/cache-enabler/
    
    # set Cache Enabler path
    SetEnvIf Request_URI "^(.*)$" CE_PATH=$1
    SetEnvIf Request_URI "^(/)index.php$" CE_PATH=$1
    
    <IfModule mod_mime.c>
    # webp HTML file
    RewriteCond %{ENV:CE_PATH} /$
    RewriteCond %{ENV:CE_PATH} !^/wp-admin/.*
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteCond %{HTTP:Accept} image/webp
    RewriteCond %{DOCUMENT_ROOT}%{ENV:SUB_PATH}%{HTTP_HOST}%{ENV:CE_PATH}index-webp.html.gz -f
    RewriteRule ^(.*) %{ENV:SUB_PATH}%{HTTP_HOST}%{ENV:CE_PATH}index-webp.html.gz [L]
    
    # gzip HTML file
    RewriteCond %{ENV:CE_PATH} /$
    RewriteCond %{ENV:CE_PATH} !^/wp-admin/.*
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteCond %{DOCUMENT_ROOT}%{ENV:SUB_PATH}%{HTTP_HOST}%{ENV:CE_PATH}index.html.gz -f
    RewriteRule ^(.*) %{ENV:SUB_PATH}%{HTTP_HOST}%{ENV:CE_PATH}index.html.gz [L]
    
    AddType text/html .gz
    AddEncoding gzip .gz
    </IfModule>
    
    # webp HTML file
    RewriteCond %{ENV:CE_PATH} /$
    RewriteCond %{ENV:CE_PATH} !^/wp-admin/.*
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_
    RewriteCond %{HTTP:Accept} image/webp
    RewriteCond %{DOCUMENT_ROOT}%{ENV:SUB_PATH}%{HTTP_HOST}%{ENV:CE_PATH}index-webp.html -f
    RewriteRule ^(.*) %{ENV:SUB_PATH}%{HTTP_HOST}%{ENV:CE_PATH}index-webp.html [L]
    
    # default HTML file
    RewriteCond %{ENV:CE_PATH} /$
    RewriteCond %{ENV:CE_PATH} !^/wp-admin/.*
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_
    RewriteCond %{DOCUMENT_ROOT}%{ENV:SUB_PATH}%{HTTP_HOST}%{ENV:CE_PATH}index.html -f
    RewriteRule ^(.*) %{ENV:SUB_PATH}%{HTTP_HOST}%{ENV:CE_PATH}index.html [L]
    
    # wp override
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [END]
    </IfModule>
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^index\.php$ - [L]
        RewriteRule (.+)/$ $1 [R=301,L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
    </IfModule>

    Thanks & regards,
    Gulshan

    https://ww.wp.xz.cn/plugins/cache-enabler/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author KeyCDN

    (@keycdn)

    What Apache and WP version do you use?

    Plugin Author KeyCDN

    (@keycdn)

    You need to double check the path and might need to adjust the variable CE_PATH. Also make sure that you are using the correct snippet for your Apache version.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Problem after removing WordPress trailing slash’ is closed to new replies.