WordPress Speed Optimization via .htaccess « RainaStudio

WordPress Speed Optimization via .htaccess

Here is some snippets to help the website to load faster. All these snippets is used for Speed Optimization via .htaccess. Code is explained below.


  • Disable Etags:

Etag is the mechanism by which a browser check a newer version of resousces from the server. So when we disable it via htaccess file. The browser then force to use the cache file.

  • Allow CDN resources

If we are using CDN for optimization the site performance, we may see warning “Cross-Origin Resources Found”. Because when CDN works on a site many resouces is served from the CDN instead of the actual server. We can add this below code to allow cross-origin access.

  • Redirect http to https via .htaccess

The below is redirecting http request to secured protocol https. To get this working you must need to install a SSl certificate to the website.

  • Security from uploading dangerous file types

We can further to improve security by denying all the dangerous file uploads by this.

  • Allow to read robot.txt from everywhere from anything for SEO

  • Gzip Compression and caching Expiration

These are the code by which we can do website speed optimization via .htacess. If you know something new please share with the comments.

Anwer Ashif

I like to quote code snippet, fix things like error 503 service unavailable. Cycling, traveling and plantation are my hobbies.