Editing .htaccess with extra caching plugins

#243233
  • Resolved Marco Agas
    Rank Math free

    Hi there,

    I’m a bit worried about editing my .htaccess file. Even though I’ve added in:

    # START of Rank Math Sitemap Rewrite Rules
    RewriteEngine On
    RewriteBase /
    RewriteRule ^sitemap_index.xml$ /index.php?sitemap=1 [L]
    RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 [L]
    RewriteRule ^([a-z]+)?-?sitemap.xsl$ /index.php?xsl=$1 [L]
    # END of Rank Math Sitemap Rewrite Rules

    A few months later and it still hasn’t updated. I feel like this is due to a caching plugin. I’ve included the .htc access info below. Could you please assist with what needs to be edited/removed. I’ve looked into adding WP Fastest Cache exclusions, however, the advanced tab is missing. Please can you assist?

    # BEGIN WpFastestCache
    # Modified Time: 19-07-21 10:26:13
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTPS} =on
    RewriteCond %{HTTP_HOST} ^www.wecprojects.com
    # Start WPFC Exclude
    # RewriteCond %{REQUEST_URI} !.sitemap..xml [NC]
    # RewriteCond %{REQUEST_URI} !.sitemap.xsl [NC]
    # End WPFC Exclude
    # Start_WPFC_Exclude_Admin_Cookie
    RewriteCond %{HTTP:Cookie} !wordpress_logged_in_[^\=]+\=Alex|Freelancer|Marco
    # End_WPFC_Exclude_Admin_Cookie
    RewriteCond %{HTTP_HOST} ^www.wecprojects.com
    RewriteCond %{HTTP_USER_AGENT} !(facebookexternalhit|WP_FASTEST_CACHE_CSS_VALIDATOR|Twitterbot|LinkedInBot|WhatsApp|Mediatoolkitbot)
    RewriteCond %{HTTP_USER_AGENT} !(WP\sFastest\sCache\sPreload(\siPhone\sMobile)?\s*Bot)
    RewriteCond %{REQUEST_METHOD} !POST
    RewriteCond %{REQUEST_URI} !(\/){2}$
    RewriteCond %{REQUEST_URI} \/$
    RewriteCond %{QUERY_STRING} !.+
    RewriteCond %{HTTP:Cookie} !comment_author_
    RewriteCond %{HTTP:Cookie} !safirmobilswitcher=mobil
    RewriteCond %{HTTP:Profile} !^[a-z0-9\”]+ [NC]
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/all/$1/index.html -f [or]
    RewriteCond /usr/www/users/wecprdywwj/wp-content/cache/all/$1/index.html -f
    RewriteRule ^(.*) “/wp-content/cache/all/$1/index.html” [L]
    </IfModule>
    <FilesMatch “index\.(html|htm)$”>
    AddDefaultCharset UTF-8
    <ifModule mod_headers.c>
    FileETag None
    Header unset ETag
    Header set Cache-Control “max-age=0, no-cache, no-store, must-revalidate”
    Header set Pragma “no-cache”
    Header set Expires “Mon, 29 Oct 1923 20:30:00 GMT”
    </ifModule>
    </FilesMatch>
    # END WpFastestCache
    # BEGIN GzipWpFastestCache
    <IfModule mod_deflate.c>
    AddType x-font/woff .woff
    AddType x-font/ttf .ttf
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE x-font/ttf
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    AddOutputFilterByType DEFLATE font/opentype font/ttf font/eot font/otf
    </IfModule>
    # END GzipWpFastestCache
    # BEGIN LBCWpFastestCache
    <FilesMatch “\.(webm|ogg|mp4|ico|pdf|flv|avif|jpg|jpeg|png|gif|webp|js|css|swf|x-html|css|xml|js|woff|woff2|otf|ttf|svg|eot)(\.gz)?$”>
    <IfModule mod_expires.c>
    AddType application/font-woff2 .woff2
    AddType application/x-font-opentype .otf
    ExpiresActive On
    ExpiresDefault A0
    ExpiresByType video/webm A10368000
    ExpiresByType video/ogg A10368000
    ExpiresByType video/mp4 A10368000
    ExpiresByType image/avif A10368000
    ExpiresByType image/webp A10368000
    ExpiresByType image/gif A10368000
    ExpiresByType image/png A10368000
    ExpiresByType image/jpg A10368000
    ExpiresByType image/jpeg A10368000
    ExpiresByType image/ico A10368000
    ExpiresByType image/svg+xml A10368000
    ExpiresByType text/css A10368000
    ExpiresByType text/javascript A10368000
    ExpiresByType application/javascript A10368000
    ExpiresByType application/x-javascript A10368000
    ExpiresByType application/font-woff2 A10368000
    ExpiresByType application/x-font-opentype A10368000
    ExpiresByType application/x-font-truetype A10368000
    </IfModule>
    <IfModule mod_headers.c>
    Header set Expires “max-age=A10368000, public”
    Header unset ETag
    Header set Connection keep-alive
    FileETag None
    </IfModule>
    </FilesMatch>
    # END LBCWpFastestCache

    # BEGIN HTTPS Redirection Plugin
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    </IfModule>
    # END HTTPS Redirection Plugin

    # BEGIN WordPress
    # The directives (lines) between “BEGIN WordPress” and “END WordPress” are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

    ## EXPIRES CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg “access 1 year”
    ExpiresByType image/jpeg “access 1 year”
    ExpiresByType image/gif “access 1 year”
    ExpiresByType image/png “access 1 year”
    ExpiresByType text/css “access 1 month”
    ExpiresByType application/pdf “access 1 month”
    ExpiresByType text/x-javascript “access 1 month”
    ExpiresByType application/x-shockwave-flash “access 1 month”
    ExpiresByType image/x-icon “access 1 year”
    ExpiresDefault “access plus 1 week”
    </IfModule>
    ## EXPIRES CACHING ##

    RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
    RewriteRule .* ? [F,L]

    <IfModule mod_gzip.c>
    mod_gzip_on Yes
    mod_gzip_dechunk Yes
    mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
    mod_gzip_item_include handler ^cgi-script$
    mod_gzip_item_include mime ^text/.*
    mod_gzip_item_include mime ^application/x-javascript.*
    mod_gzip_item_exclude mime ^image/.*
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
    </IfModule>

    # Image Expires Tag
    <IfModule mod_expires.c>
    ExpiresActive on

    ExpiresByType image/jpg “access plus 1 month”
    ExpiresByType image/jpeg “access plus 1 month”
    ExpiresByType image/gif “access plus 1 month”
    ExpiresByType image/png “access plus 1 month”
    </IfModule>

    ## EXPIRES CACHING ##

    # START of Rank Math Sitemap Rewrite Rules
    RewriteEngine On
    RewriteBase /
    RewriteRule ^sitemap_index.xml$ /index.php?sitemap=1 [L]
    RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 [L]
    RewriteRule ^([a-z]+)?-?sitemap.xsl$ /index.php?xsl=$1 [L]
    # END of Rank Math Sitemap Rewrite Rules

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello,

    Thank you for contacting Rank Math today.

    The .htaccess is very specific for each installation and use case and we can’t give a full overview of what should or can be included in that file.

    ​​​​​​Having said that, looking at the file it seems that most entries are automatically inserted by your caching plugin except for the latest entries which are related to Rank Math and should be included only if are having trouble with the sitemaps.

    If at any point you experience any issues that might be related to this file you can always try setting a default file like this one for testing purposes: https://wpmarks.com/default-wordpress-htaccess/

    Hope this helps clarify your doubts.

    Don’t hesitate to get in touch if you have any other questions.

    Hi Miguel,

    Thanks! And sorry for the late reply. I added in those RankMath entries as my site wasn’t reflecting the updates I’ve made to it. Following on from a previous ticket, they said to wait a few weeks, which I did. I’m not sure if any of the entries above are conflicting are not.

    I’ve removed the caching plugins now on my site – so could I just use that clean htcaccess file you recommended and then re-add the RankMath entries?

    Prabhat
    Rank Math agency

    Hello,

    I added in those RankMath entries as my site wasn’t reflecting the updates I’ve made to it.

    Could you confirm if you mean that your sitemap was not reflecting the latest updates?

    If yes and you’ve disabled the caching plugin, then please flush the Sitemap cache by following this video screencast:
    https://i.rankmath.com/pipRDp

    Then, clear your website and browser’s cache and see if that fixes the issue.

    Please let us know how that goes.

    Thank you.

    Hi Prabhat,

    Could you confirm if you mean that your sitemap was not reflecting the latest updates? – Yes so I included those entries in the htaccess as things like meta descriptions haven’t been updated in months. From a previous ticket, they mentioned to include these entries as it was still linked to the old original sitemap.

    For new pages/URLs it picks up the new meta descriptions. However old meta descriptions and the original pages, even though I’ve updated them multiple times, haven’t changed. Please can you assist?

    For example: https://www.wecprojects.com/contact-us is excluded from the sitemap. I have no idea how or why, but it is. I’ve submitted the new sitemap, however, it’s still not showing up.

    Hello,

    We have checked that page and is already included in the sitemap.

    Please check the screenshot in the sensitive data section.

    However, we discovered an issue in your robots.txt file, that has the sitemap URL wrong. It should read something like this:

    
    Sitemap: https://www.wecprojects.com/sitemap_index.xml
    

    After doing that, also make sure that you submit the sitemap to Google Search Console by following this guide: https://rankmath.com/kb/submit-sitemap-to-google/

    Hope this helps clarify your doubts and solve the issues.

    Don’t hesitate to get in touch if you require any further assistance.

    Hi Miguel,

    Thanks so much! I’ve edited the robots page. And my site is already indexed in Google Search Console – should I resubmit it?

    Hello,

    Since the page is already indexed on the search results pages, you can skip that step as it seems that this issue was due to the wrong sitemap URL you have in your robots.txt.

    Let us know if the issue still persists so we can check as well.

    I hope that helps.

    Thank you, and please don’t hesitate to contact us anytime if you need further assistance with anything else.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘Editing .htaccess with extra caching plugins’ is closed to new replies.