My advice to you is not to worry about adding in the copious amount of .htaccess rules for forcing browser caching and setting correct expire time values for assets. If you download the W3 Total Cache plugin it handles adding all of the above into your .htaccess file for you.
If you would prefer not to install the caching plugin, I’ve taken the liberty of opening up my own sites .htaccess file and copying the optimisation rules and put them into a Github Gist for you.
Paste all of the code in the Gist at the top of your .htaccess file before the “# BEGIN WordPress” comment.
The Gist can be seen here.
Related Posts:
- Enable webp support Nginx+Apache reverse proxy with moss.sh [closed]
- Best collection of code for your .htaccess file [closed]
- Default .htaccess file for WordPress?
- Which one does WordPress prioritize when it comes to php.ini, wp-config and .htaccess?
- Improve wordpress security by hiding non public resources
- WordPress site hacked. Has .htaccess been hacked?
- Does this .htaccess security setting really work?
- htaccess problem after saving Settings
- Stop WordPress and Plugins from Overwriting .htaccess
- File and directory permissions
- htaccess disable WordPress rewrite rules for folder and its contents
- htaccess rewrite conflict with wordpress rules and ssl
- htaccess https redirect from www to non-www
- Htaccess for Wordpess set on single subdomain
- adding rewrite rules in .htaccess
- .htaccess and 500 error, extra character added
- Name-based virtual host configuration in Apache seems to cause a “500 Internal Server Error”
- Place static HTML files in path below WordPress page
- Static raw HTML page
- WordPress + Magento .htaccess ReWriteRule Issue (www vs. non-www)
- Plugin to edit htaccess file
- htaccess rewrite for author query string when WP is in subfolder
- Why “Settings->Permalinks” creates .htaccess file on nginx server?
- .htaccess for wordpress inside another wordpress install
- .htaccess file redirecting to parent directory
- Blog.php or how to display recent posts?
- Rewrite /?rest_route=/ link to /wp-json/ without changing default permalink structure in apache
- Globally force SSL on all pages
- Serve apache 404 for missing assets rather then wp 404 template WP_Rewrites
- Isolating WordPress to a subfolder
- Remove year and month in URL using .htaccess
- index.php not loading in main folder of wordpress
- Admin-Ajax.php, SSL, Non-SSL
- How disable SSL redirect for specific URL?
- WordPress site displaying 404 for any page apart from index
- Why does the header set X-Robots-Tag apply to all pages?
- Permalinks not working on second wordpress installed in a subdirect
- How to avoid wordpress permalink rules to inherit in a sub-folder
- Error:406 not acceptable
- Unable to access WP admin
- .htaccess Rewrite URL WordPress
- Move wordpress to folder without changing urls
- Rewrite rule not working
- A plugin changes my .htaccess file and I can’t access httpd.conf as that’s a shared server
- Cant block wordpress readme files
- Change wp-content without changing the name of the folder
- 404/500 error on /wp-json
- WordPress keeps deleting .htaccess file
- Correct htaccess to display page while also passing in GET parameters
- What is the role of .htaccess file in WordPress?
- Using “wordpress_logged_in” to restrict direct access to uploads folder in 2021
- Using WordPress only for the backend, and using AngularJS as a frontend
- Temporary .htaccess blocking is disabling WP Crons from running?
- How to restrict access to wp-content, wp-includes and all sub-folders
- Two domains on one WordPress Installation
- .htaccess redirects disappeared after re-saving permalinks
- Protect Upload Folder Files With Ampersand Problem
- How have I misconfigured basic auth for my wordpress site?
- Remove File Extension for Page Outside of WordPress
- Is it possible to dynamically redirect URL using htaccess?
- How can I code my plugin to safely modify .htaccess?
- Prevent users from browsing through the media galleries
- .htaccess for wordpress in separate folder
- How to modify the .htaccess to force ssl on login and admin pages
- WordPress URL/Folder ReWrite using Htaccess
- WordPress trims off the forward slash when import
- Which WordPress scripts need to be executable for a fresh installation?
- WordPress mod_rewrite is canceling/overwriting my other mod_rewrite rule
- .htaccess and WordPress Admin Bar
- WordPress best solution shared theme for consumers and businesses (two url’s one instaltion)
- Keep getting 401 error from WordPress on AWS Lightsail
- Redirect main domain to subdirectory
- Blocking access to wp-login via htaccess not working
- HTAccess stops me from accessing WordPress Dashboard links
- Setup Permanent 301 Redirects after moving to Https [closed]
- .htaccess redirects no longer work
- Force www to non-www on a subdomain in WordPress?
- WordPress multilingual website domain and folders
- Exclude subfolder from WP-redirect works with html but not php files
- How to Redirect huge numbers of URLs to another URLs?
- Attach to wp-login.php and xmlrpc.php
- WP site URL changed to have HTTPS but still homepage does not redirect
- different child theme for subdomain
- Struggling with add_rewrite_rule
- Server crashed trying to restore wordpress multisite, images are not found pls help
- Giving WordPress its own subdirectory – nginx
- Block only external access to wp-cron.php on OpenLiteSpeed
- Create subdomain masking for each user in WordPress
- Redirect from different port to subdomain – htaccess
- Cannot mask WordPress page URL using .htaccess
- Removing code added to htaccess with insert_with_markers
- .htaccess rewrite rule puzzle
- need a help for modify .htaccess rule [closed]
- Question with loading 403/ 404 error pages and htaccess
- WordPress Redirect 301 register page
- How can I make an htaccess file on a Mac? [closed]
- Site searches by Python for non-existent assets
- Allow logged in users who doesn’t belong to whitelisted ips
- WordPress On subfolder
- Best way to redirect site in subdirectory to root?