{"id":41781,"date":"2024-12-17T01:59:44","date_gmt":"2024-12-16T23:59:44","guid":{"rendered":"https:\/\/coma.lv\/2024\/12\/17\/how-to-speed-up-wordpress-and-protect-your-site-with-htaccess-and-no-plugins-at\/"},"modified":"2024-12-17T01:59:44","modified_gmt":"2024-12-16T23:59:44","slug":"how-to-speed-up-wordpress-and-protect-your-site-with-htaccess-and-no-plugins-at","status":"publish","type":"post","link":"https:\/\/coma.lv\/en\/2024\/12\/17\/how-to-speed-up-wordpress-and-protect-your-site-with-htaccess-and-no-plugins-at\/","title":{"rendered":"How to Speed Up WordPress and Protect Your Site with .htaccess and No Plugins at All"},"content":{"rendered":"\n<p style=\"text-align: left;\">Do you need to protect your WordPress site? Then here is a good way that requires using ONLY .htaccess<\/p>\n<h2 style=\"text-align: left;\">What Is .htaccess<\/h2>\n<p style=\"text-align: left;\">.htaccess is a configuration file on Apache servers. Placed in the appropriate directory, the file is detected and processed by the Apache software. This file is used to enable and disable features that Apache has. Among these features are redirects for 404 pages, as well as more advanced things such as blocking image hotlinking, cache compression management, password protection of content and much more, which you can learn about <a href=\"http:\/\/www.htaccess-guide.com\/\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<h2 style=\"text-align: left;\">How Does All This Work?<\/h2>\n<p style=\"text-align: left;\">I have the idea of avoiding huge libraries from lots of plugins and settings that I place on the server. For this purpose I use .htaccess<\/p>\n<h2 style=\"text-align: left;\">Enabling Gzip in WordPress with .htaccess<\/h2>\n<p style=\"text-align: left;\">To enable gzip in your WordPress you need to enable mod_deflate.c and use suitable filters. For example, these:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&amp;lt;ifmodule mod_deflate.c&amp;gt;\r\n\tAddOutputFilterByType DEFLATE text\/plain\r\n\tAddOutputFilterByType DEFLATE text\/text\r\n\tAddOutputFilterByType DEFLATE text\/html\r\n\tAddOutputFilterByType DEFLATE text\/plain\r\n\tAddOutputFilterByType DEFLATE text\/xml\r\n\tAddOutputFilterByType DEFLATE text\/css\r\n\tAddOutputFilterByType DEFLATE image\/gif\r\n\tAddOutputFilterByType DEFLATE image\/jpeg\r\n\tAddOutputFilterByType DEFLATE image\/jpg\r\n\tAddOutputFilterByType DEFLATE image\/png\r\n\tAddOutputFilterByType DEFLATE image\/gif\r\n\tAddOutputFilterByType DEFLATE image\/flv\r\n\tAddOutputFilterByType DEFLATE image\/ico\r\n\tAddOutputFilterByType DEFLATE image\/swf\r\n\tAddOutputFilterByType DEFLATE application\/rss+xml \r\n\tAddOutputFilterByType DEFLATE application\/xhtml+xml\r\n\tAddOutputFilterByType DEFLATE application\/xml\r\n\tAddOutputFilterByType DEFLATE application\/x-javascript\r\n\tAddOutputFilterByType DEFLATE application\/javascript\r\n\tAddOutputFilterByType DEFLATE application\/json\r\n\tAddOutputFilterByType DEFLATE video\/3gpp\r\n\tAddOutputFilterByType DEFLATE video\/3gpp2\r\n\tAddOutputFilterByType DEFLATE video\/x-flv\r\n\tAddOutputFilterByType DEFLATE video\/jpm\r\n\tAddOutputFilterByType DEFLATE video\/jpeg\r\n\tAddOutputFilterByType DEFLATE video\/x-m4v\r\n\tAddOutputFilterByType DEFLATE video\/mp4\r\n\tAddOutputFilterByType DEFLATE video\/ogg\r\n\tAddOutputFilterByType DEFLATE video\/webm\r\n\tAddOutputFilterByType DEFLATE video\/quicktime\r\n\tAddOutputFilterByType DEFLATE audio\/x-mpegurl\r\n\tAddOutputFilterByType DEFLATE audio\/midi\r\n\tAddOutputFilterByType DEFLATE audio\/mp3\r\n\tAddOutputFilterByType DEFLATE audio\/mp4\r\n\tAddOutputFilterByType DEFLATE audio\/mpeg\r\n\tAddOutputFilterByType DEFLATE audio\/webm\r\n\tAddOutputFilterByType DEFLATE audio\/basic\r\n\tAddOutputFilterByType DEFLATE audio\/x-wav\r\n\tAddOutputFilterByType DEFLATE audio\/wav\r\n\t\r\n\t# Fix Browsers\r\n\tBrowserMatch ^Mozilla\/4 gzip-only-text\/html\r\n\tBrowserMatch ^Mozilla\/4\\.0&#x5B;678] no-gzip\r\n\tBrowserMatch \\bMSIE !no-gzip !gzip-only-text\/html\r\n&amp;lt;\/ifmodule&amp;gt;\r\n<\/pre>\n<p style=\"text-align: left;\">This example covers all the important media types you need. By enabling this in your .htaccess, you will get the best performance and loading time for your site. The only exception is Mozilla, some versions of which do not support Gzip.<\/p>\n<h2 style=\"text-align: left;\">Configuring the WordPress Cache in .htaccess<\/h2>\n<p style=\"text-align: left;\">If you want to speed up your site by caching JavaScript, CSS and images, you can easily configure this through .htaccess by enabling mod_expires.c<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n# Expires - 2678400s = 31 days\r\n&amp;lt;ifmodule mod_expires.c&amp;gt;\r\n\tExpiresActive On\r\n\tExpiresDefault &amp;quot;access plus 1 seconds&amp;quot;\r\n\tExpiresByType text\/html &amp;quot;access plus 7200 seconds&amp;quot;\r\n\tExpiresByType image\/gif &amp;quot;access plus 2678400 seconds&amp;quot;\r\n\tExpiresByType image\/jpeg &amp;quot;access plus 2678400 seconds&amp;quot;\r\n\tExpiresByType image\/png &amp;quot;access plus 2678400 seconds&amp;quot;\r\n\tExpiresByType text\/css &amp;quot;access plus 518400 seconds&amp;quot;\r\n\tExpiresByType text\/javascript &amp;quot;access plus 2678400 seconds&amp;quot;\r\n\tExpiresByType application\/x-javascript &amp;quot;access plus 2678400 seconds&amp;quot;\r\n&amp;lt;\/ifmodule&amp;gt;\r\n<\/pre>\n<p style=\"text-align: left;\">In my example I use caching for 31 days. You can change this setting to the one you need. And here is the code for headers:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n# Cache Headers\r\n&amp;lt;ifmodule mod_headers.c&amp;gt;\r\n\t# Cache specified files for 31 days\r\n\t&amp;lt;filesmatch &amp;quot;\\.(ico|flv|jpg|jpeg|png|gif|css|swf)$&amp;quot;&amp;gt;\r\n\t\tHeader set Cache-Control &amp;quot;max-age=2678400, public&amp;quot;\r\n\t&amp;lt;\/filesmatch&amp;gt;\r\n\t# Cache HTML files for a couple hours\r\n\t&amp;lt;filesmatch &amp;quot;\\.(html|htm)$&amp;quot;&amp;gt;\r\n\t\tHeader set Cache-Control &amp;quot;max-age=7200, private, must-revalidate&amp;quot;\r\n\t&amp;lt;\/filesmatch&amp;gt;\r\n\t# Cache PDFs for a day\r\n\t&amp;lt;filesmatch &amp;quot;\\.(pdf)$&amp;quot;&amp;gt;\r\n\t\tHeader set Cache-Control &amp;quot;max-age=86400, public&amp;quot;\r\n\t&amp;lt;\/filesmatch&amp;gt;\r\n\t# Cache Javascripts for 31 days\r\n\t&amp;lt;filesmatch &amp;quot;\\.(js)$&amp;quot;&amp;gt;\r\n\t\tHeader set Cache-Control &amp;quot;max-age=2678400, private&amp;quot;\r\n\t&amp;lt;\/filesmatch&amp;gt;\r\n&amp;lt;\/ifmodule&amp;gt;\r\n<\/pre>\n<p style=\"text-align: left;\">You can configure the max-age parameter however you like.<\/p>\n<h2 style=\"text-align: left;\">Protecting Your WordPress Installation with .htaccess<\/h2>\n<p style=\"text-align: left;\">In fact, WordPress is quite vulnerable to attackers, but you can make their job harder. Yes, there are plugins that offer decent protection, but in some cases .htaccess can be a much more effective solution.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n# Disable directory browsing\r\nOptions All -Indexes\r\n\r\n# Deny access to wp-config.php file\r\n&amp;lt;files wp-config.php&amp;gt;\r\n\torder allow,deny\r\n\tdeny from all\r\n&amp;lt;\/files&amp;gt;\r\n\r\n# Deny access to xmlrpc.php file *** REMOVE THIS IF YOU WANT TO ACCESS IT ***\r\n&amp;lt;files xmlrpc.php&amp;gt;\r\n\torder allow,deny\r\n\tdeny from all\r\n&amp;lt;\/files&amp;gt;\r\n\r\n# Deny access to all .htaccess files\r\n&amp;lt;files ~ &amp;quot;^.*\\.(&#x5B;Hh]&#x5B;Tt]&#x5B;Aa])&amp;quot;&amp;gt;\r\n\torder allow,deny\r\n\tdeny from all\r\n\tsatisfy all\r\n&amp;lt;\/files&amp;gt;\r\n\r\n# Block wp-includes folder and files\r\n&amp;lt;IfModule mod_rewrite.c&amp;gt;\r\n\tRewriteEngine On\r\n\tRewriteBase \/\r\n\tRewriteRule ^wp-admin\/includes\/ - &#x5B;F,L]\r\n\tRewriteRule !^wp-includes\/ - &#x5B;S=3]\r\n\tRewriteRule ^wp-includes\/&#x5B;^\/]+\\.php$ - &#x5B;F,L]\r\n\tRewriteRule ^wp-includes\/js\/tinymce\/langs\/.+\\.php - &#x5B;F,L]\r\n\tRewriteRule ^wp-includes\/theme-compat\/ - &#x5B;F,L]\r\n&amp;lt;\/IfModule&amp;gt;\r\n\r\n# Block Massive attacks\r\n&amp;lt;IfModule mod_rewrite.c&amp;gt;\r\n\tRewriteEngine On\r\n\t# Block out any script trying to base64_encode data within the URL.\r\n\tRewriteCond %{QUERY_STRING} base64_encode&#x5B;^(]*\\(&#x5B;^)]*\\) &#x5B;OR]\r\n\t# Block out any script that includes a &amp;lt;script&amp;gt; tag in URL.\r\n\tRewriteCond %{QUERY_STRING} (&amp;lt;|%3C)(&#x5B;^s]*s)+cript.*(&amp;gt;|%3E) &#x5B;NC,OR]\r\n\t# Block out any script trying to set a PHP GLOBALS variable via URL.\r\n\tRewriteCond %{QUERY_STRING} GLOBALS(=|\\&#x5B;|\\%&#x5B;0-9A-Z]{0,2}) &#x5B;OR]\r\n\t# Block out any script trying to modify a _REQUEST variable via URL.\r\n\tRewriteCond %{QUERY_STRING} _REQUEST(=|\\&#x5B;|\\%&#x5B;0-9A-Z]{0,2})\r\n\t# Return 403 Forbidden header and show the content of the root homepage\r\n\tRewriteRule .* index.php &#x5B;F]\r\n\t\r\n\tRewriteCond %{REQUEST_FILENAME} !-f\r\n\tRewriteCond %{REQUEST_FILENAME} !-d\r\n\r\n\t# Disable user agents from this locations\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Missigua Locator&amp;quot; bad_bot\r\n\t#SetEnvIfNoCase User-Agent &amp;quot;^PEAR HTTP_Request class&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Java\/1.4.1&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Java\/1.5.0&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^psycheclone&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^WEP Search 00&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^FlashGet&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^GetRight&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^GetWeb!&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Go!Zilla&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^httplib&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Indy Library&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^InfoNaviRobot&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^InterGET&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Internet Ninja&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^LexiBot&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^libWeb\/clsHTTP&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^libwww&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^libwww-perl&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^LinkextractorPro&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Mozilla.*NEWT&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Octopus&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^ProWebWalker&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^SuperBot&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^WebAuto&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Wells Search II&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Wget&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^wget&amp;quot; bad_bot\r\n\r\n\t&amp;lt;Limit GET POST&amp;gt;\r\n\t\torder allow,deny\r\n\t\tallow from all\r\n\t\tdeny from env=bad_bot\r\n\t&amp;lt;\/Limit&amp;gt;\r\n&amp;lt;\/IfModule&amp;gt;\r\n<\/pre>\n<p style=\"text-align: left;\">First of all, I forced indexing off in places where there is direct access. This is in case someone wants to get direct access to some folders and see the list of files inside them.<\/p>\n<p style=\"text-align: left;\">The next protection measure was disabling direct access to the <em>.htaccess<\/em>, <em>xmlrpc.php<\/em> and <em>wp-config.php<\/em> files.<\/p>\n<p style=\"text-align: left;\">Important note: if you need the <em>xmlrpc.php<\/em> file, you need to remove the corresponding part of the code.<\/p>\n<p style=\"text-align: left;\">The next protection measure was disabling access to certain files and folders inside the folder with the installed system.<\/p>\n<p style=\"text-align: left;\">The last protection measure was protection from spam and hacking attacks coming from various spiders and bots.<\/p>\n<h2 style=\"text-align: left;\">Conclusions<\/h2>\n<p style=\"text-align: left;\">.htaccess is a powerful tool if you understand its syntax. However, as an example to build on, we offer you the following code, which you can of course change to suit your requirements.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n# Enable GZIP\r\n&amp;lt;ifmodule mod_deflate.c&amp;gt;\r\n\tAddOutputFilterByType DEFLATE text\/plain\r\n\tAddOutputFilterByType DEFLATE text\/text\r\n\tAddOutputFilterByType DEFLATE text\/html\r\n\tAddOutputFilterByType DEFLATE text\/plain\r\n\tAddOutputFilterByType DEFLATE text\/xml\r\n\tAddOutputFilterByType DEFLATE text\/css\r\n\tAddOutputFilterByType DEFLATE image\/gif\r\n\tAddOutputFilterByType DEFLATE image\/jpeg\r\n\tAddOutputFilterByType DEFLATE image\/jpg\r\n\tAddOutputFilterByType DEFLATE image\/png\r\n\tAddOutputFilterByType DEFLATE image\/gif\r\n\tAddOutputFilterByType DEFLATE image\/flv\r\n\tAddOutputFilterByType DEFLATE image\/ico\r\n\tAddOutputFilterByType DEFLATE image\/swf\r\n\tAddOutputFilterByType DEFLATE application\/rss+xml \r\n\tAddOutputFilterByType DEFLATE application\/xhtml+xml\r\n\tAddOutputFilterByType DEFLATE application\/xml\r\n\tAddOutputFilterByType DEFLATE application\/x-javascript\r\n\tAddOutputFilterByType DEFLATE application\/javascript\r\n\tAddOutputFilterByType DEFLATE application\/json\r\n\tAddOutputFilterByType DEFLATE video\/3gpp\r\n\tAddOutputFilterByType DEFLATE video\/3gpp2\r\n\tAddOutputFilterByType DEFLATE video\/x-flv\r\n\tAddOutputFilterByType DEFLATE video\/jpm\r\n\tAddOutputFilterByType DEFLATE video\/jpeg\r\n\tAddOutputFilterByType DEFLATE video\/x-m4v\r\n\tAddOutputFilterByType DEFLATE video\/mp4\r\n\tAddOutputFilterByType DEFLATE video\/ogg\r\n\tAddOutputFilterByType DEFLATE video\/webm\r\n\tAddOutputFilterByType DEFLATE video\/quicktime\r\n\tAddOutputFilterByType DEFLATE audio\/x-mpegurl\r\n\tAddOutputFilterByType DEFLATE audio\/midi\r\n\tAddOutputFilterByType DEFLATE audio\/mp3\r\n\tAddOutputFilterByType DEFLATE audio\/mp4\r\n\tAddOutputFilterByType DEFLATE audio\/mpeg\r\n\tAddOutputFilterByType DEFLATE audio\/webm\r\n\tAddOutputFilterByType DEFLATE audio\/basic\r\n\tAddOutputFilterByType DEFLATE audio\/x-wav\r\n\tAddOutputFilterByType DEFLATE audio\/wav\r\n\t\r\n\t# Fix Browsers\r\n\tBrowserMatch ^Mozilla\/4 gzip-only-text\/html\r\n\tBrowserMatch ^Mozilla\/4\\.0&#x5B;678] no-gzip\r\n\tBrowserMatch \\bMSIE !no-gzip !gzip-only-text\/html\r\n&amp;lt;\/ifmodule&amp;gt;\r\n\r\n# Expires Headers - 2678400s = 31 days\r\n&amp;lt;ifmodule mod_expires.c&amp;gt;\r\n\tExpiresActive On\r\n\tExpiresDefault &amp;quot;access plus 1 seconds&amp;quot;\r\n\tExpiresByType text\/html &amp;quot;access plus 7200 seconds&amp;quot;\r\n\tExpiresByType image\/gif &amp;quot;access plus 2678400 seconds&amp;quot;\r\n\tExpiresByType image\/jpeg &amp;quot;access plus 2678400 seconds&amp;quot;\r\n\tExpiresByType image\/png &amp;quot;access plus 2678400 seconds&amp;quot;\r\n\tExpiresByType text\/css &amp;quot;access plus 518400 seconds&amp;quot;\r\n\tExpiresByType text\/javascript &amp;quot;access plus 2678400 seconds&amp;quot;\r\n\tExpiresByType application\/x-javascript &amp;quot;access plus 2678400 seconds&amp;quot;\r\n&amp;lt;\/ifmodule&amp;gt;\r\n\r\n# Cache Headers\r\n&amp;lt;ifmodule mod_headers.c&amp;gt;\r\n\t# Cache specified files for 31 days\r\n\t&amp;lt;filesmatch &amp;quot;\\.(ico|flv|jpg|jpeg|png|gif|css|swf)$&amp;quot;&amp;gt;\r\n\t\tHeader set Cache-Control &amp;quot;max-age=2678400, public&amp;quot;\r\n\t&amp;lt;\/filesmatch&amp;gt;\r\n\t# Cache HTML files for a couple hours\r\n\t&amp;lt;filesmatch &amp;quot;\\.(html|htm)$&amp;quot;&amp;gt;\r\n\t\tHeader set Cache-Control &amp;quot;max-age=7200, private, must-revalidate&amp;quot;\r\n\t&amp;lt;\/filesmatch&amp;gt;\r\n\t# Cache PDFs for a day\r\n\t&amp;lt;filesmatch &amp;quot;\\.(pdf)$&amp;quot;&amp;gt;\r\n\t\tHeader set Cache-Control &amp;quot;max-age=86400, public&amp;quot;\r\n\t&amp;lt;\/filesmatch&amp;gt;\r\n\t# Cache Javascripts for 31 days\r\n\t&amp;lt;filesmatch &amp;quot;\\.(js)$&amp;quot;&amp;gt;\r\n\t\tHeader set Cache-Control &amp;quot;max-age=2678400, private&amp;quot;\r\n\t&amp;lt;\/filesmatch&amp;gt;\r\n&amp;lt;\/ifmodule&amp;gt;\r\n\r\n# Disable directory browsing\r\nOptions All -Indexes\r\n\r\n# Deny access to wp-config.php file\r\n&amp;lt;files wp-config.php&amp;gt;\r\n\torder allow,deny\r\n\tdeny from all\r\n&amp;lt;\/files&amp;gt;\r\n\r\n# Deny access to xmlrpc.php file *** REMOVE THIS IF YOU WANT TO ACCESS IT ***\r\n&amp;lt;files xmlrpc.php&amp;gt;\r\n\torder allow,deny\r\n\tdeny from all\r\n&amp;lt;\/files&amp;gt;\r\n\r\n# Deny access to all .htaccess files\r\n&amp;lt;files ~ &amp;quot;^.*\\.(&#x5B;Hh]&#x5B;Tt]&#x5B;Aa])&amp;quot;&amp;gt;\r\n\torder allow,deny\r\n\tdeny from all\r\n\tsatisfy all\r\n&amp;lt;\/files&amp;gt;\r\n\r\n# Block wp-includes folder and files\r\n&amp;lt;IfModule mod_rewrite.c&amp;gt;\r\n\tRewriteEngine On\r\n\tRewriteBase \/\r\n\tRewriteRule ^wp-admin\/includes\/ - &#x5B;F,L]\r\n\tRewriteRule !^wp-includes\/ - &#x5B;S=3]\r\n\tRewriteRule ^wp-includes\/&#x5B;^\/]+\\.php$ - &#x5B;F,L]\r\n\tRewriteRule ^wp-includes\/js\/tinymce\/langs\/.+\\.php - &#x5B;F,L]\r\n\tRewriteRule ^wp-includes\/theme-compat\/ - &#x5B;F,L]\r\n&amp;lt;\/IfModule&amp;gt;\r\n\r\n# Block Massive attacks\r\n&amp;lt;IfModule mod_rewrite.c&amp;gt;\r\n\tRewriteEngine On\r\n\t# Block out any script trying to base64_encode data within the URL.\r\n\tRewriteCond %{QUERY_STRING} base64_encode&#x5B;^(]*\\(&#x5B;^)]*\\) &#x5B;OR]\r\n\t# Block out any script that includes a &amp;lt;script&amp;gt; tag in URL.\r\n\tRewriteCond %{QUERY_STRING} (&amp;lt;|%3C)(&#x5B;^s]*s)+cript.*(&amp;gt;|%3E) &#x5B;NC,OR]\r\n\t# Block out any script trying to set a PHP GLOBALS variable via URL.\r\n\tRewriteCond %{QUERY_STRING} GLOBALS(=|\\&#x5B;|\\%&#x5B;0-9A-Z]{0,2}) &#x5B;OR]\r\n\t# Block out any script trying to modify a _REQUEST variable via URL.\r\n\tRewriteCond %{QUERY_STRING} _REQUEST(=|\\&#x5B;|\\%&#x5B;0-9A-Z]{0,2})\r\n\t# Return 403 Forbidden header and show the content of the root homepage\r\n\tRewriteRule .* index.php &#x5B;F]\r\n\t\r\n\tRewriteCond %{REQUEST_FILENAME} !-f\r\n\tRewriteCond %{REQUEST_FILENAME} !-d\r\n\r\n\t# Disable user agents from this locations\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Missigua Locator&amp;quot; bad_bot\r\n\t#SetEnvIfNoCase User-Agent &amp;quot;^PEAR HTTP_Request class&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Java\/1.4.1&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Java\/1.5.0&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^psycheclone&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^WEP Search 00&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^FlashGet&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^GetRight&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^GetWeb!&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Go!Zilla&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^httplib&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Indy Library&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^InfoNaviRobot&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^InterGET&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Internet Ninja&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^LexiBot&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^libWeb\/clsHTTP&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^libwww&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^libwww-perl&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^LinkextractorPro&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Mozilla.*NEWT&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Octopus&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^ProWebWalker&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^SuperBot&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^WebAuto&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Wells Search II&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^Wget&amp;quot; bad_bot\r\n\tSetEnvIfNoCase User-Agent &amp;quot;^wget&amp;quot; bad_bot\r\n\r\n\t&amp;lt;Limit GET POST&amp;gt;\r\n\t\torder allow,deny\r\n\t\tallow from all\r\n\t\tdeny from env=bad_bot\r\n\t&amp;lt;\/Limit&amp;gt;\r\n&amp;lt;\/IfModule&amp;gt;\r\n\r\n# BEGIN WordPress\r\n&amp;lt;IfModule mod_rewrite.c&amp;gt;\r\n\tRewriteEngine On\r\n\tRewriteBase \/\r\n\tRewriteRule ^index\\.php$ - &#x5B;L]\r\n\tRewriteCond %{REQUEST_FILENAME} !-f\r\n\tRewriteCond %{REQUEST_FILENAME} !-d\r\n\tRewriteRule . \/index.php &#x5B;L]\r\n&amp;lt;\/IfModule&amp;gt;\r\n# END WordPress\r\n<\/pre>\n<p style=\"text-align: left;\">But note that before you try our code, you MUST make the appropriate backups.<\/p>\n<p style=\"text-align: left;\">We are not responsible if something goes wrong or stops working as before. Our example works on many systems without any problems, but there is always a small chance that something will go wrong. So use the solution we offer at your own risk.<\/p>\n<p style=\"text-align: left;\">You should also understand that this is not a universal solution. If you want higher speed, better optimization and better conversion, you have to do many other things to get exactly the result you want. Or hire a designer who knows all of this inside out.<\/p>\n<hr \/>\n<p style=\"text-align: left;\"><em>Our specialization is WordPress website development and maintenance. Contact us for a free consultation \u2014 <a href=\"mailto:vadim@coma.lv\">vadim@coma.lv<\/a>, <a href=\"tel:+37129394520\">+371 29394520<\/a><\/em><\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>Do you need to protect your WordPress site? Then here is a good way that requires using ONLY .htaccess What Is .htaccess .htaccess is a configuration file on Apache servers. Placed in the appropriate directory, the file is detected and processed by the Apache software. This file is used to enable and disable features that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":38410,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1225,1407],"tags":[],"class_list":["post-41781","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","category-tutorials"],"_links":{"self":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts\/41781","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/comments?post=41781"}],"version-history":[{"count":0,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts\/41781\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/media\/38410"}],"wp:attachment":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/media?parent=41781"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/categories?post=41781"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/tags?post=41781"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}