{"id":4216,"date":"2020-09-04T15:29:41","date_gmt":"2020-09-04T12:29:41","guid":{"rendered":"https:\/\/www.margarit.com.tr\/?p=4216"},"modified":"2020-09-10T00:46:59","modified_gmt":"2020-09-09T21:46:59","slug":"optimize-edilmis-htaccess-2020-wordpress","status":"publish","type":"post","link":"https:\/\/www.margarit.com.tr\/en\/optimize-edilmis-htaccess-2020-wordpress\/","title":{"rendered":"Optimized htaccess 2020 WordPress"},"content":{"rendered":"<p>We are with you with the 2020 version of the htaccess file optimized for WordPress.<\/p>\n\n\n\n<p>An htaccess has been created jointly on a webmaster site and we copy it here for both myself and you to be permanent, let&#039;s archive it.<\/p>\n\n\n\n<p>I hope it will have an optimization quality effect when you try it on your own systems.<\/p>\n\n\n\n<p>Please do not be misled by the values shown in benchmark tools such as Pingdom, GTMetrix, WebPageTest.<\/p>\n\n\n\n<p>Try your site yourself, you will agree when you see the speed difference.<\/p>\n\n\n\n<p>Thank you.<\/p>\n\n\n\n<p>The .htaccess file applied with the permalinks created by the WordPress system during the standard initial installation:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-lang=\"PHP\"><code># BEGIN WordPress RewriteRule ^index.php$ \u2013 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . \/index.php [L] # END WordPress<\/code><\/pre><\/div>\n\n\n\n<p>Below is the .htaccess file optimized for 2020 up-to-date WordPress.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-lang=\"PHP\"><code># BEGIN WordPress\n&lt;IfModule mod_rewrite.c&gt;\nRewriteEngine On\nRewriteBase \/\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule . \/index.php [L]\nRewriteCond %{HTTP_USER_AGENT} (havij|libwww-perl|wget|python|nikto|curl|scan|java|winhttp|clshttp|loader) [NC,OR]\nRewriteCond %{HTTP_USER_AGENT} (%0A|%0D|%27|%3C|%3E|%00) [NC,OR]\nRewriteCond %{HTTP_USER_AGENT} (;|&lt;|&gt;|&#39;|&quot;|)|(|%0A|%0D|%22|%27|%28|%3C|%3E|%00).*(libwww-perl|wget|python|nikto|curl|scan|java|winhttp|HTTrack|clshttp|archiver|loader|email|harvest|extract|grab|miner) [NC,OR]\nRewriteCond %{THE_REQUEST} ? HTTP\/ [NC,OR]\nRewriteCond %{THE_REQUEST} \/* HTTP\/ [NC,OR]\nRewriteCond %{THE_REQUEST} etc\/passwd [NC,OR]\nRewriteCond %{THE_REQUEST} cgi-bin [NC,OR]\nRewriteCond %{THE_REQUEST} (%0A|%0D|r|n) [NC,OR]\nRewriteCond %{REQUEST_URI} owssvr.dll [NC,OR]\nRewriteCond %{HTTP_REFERER} (%0A|%0D|%27|%3C|%3E|%00) [NC,OR]\nRewriteCond %{HTTP_REFERER} .opendirviewer. [NC,OR]\nRewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http:\/\/ [NC,OR]\nRewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=(..\/\/?)+ [NC,OR]\nRewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=\/([a-z0-9_.]\/\/?)+ [NC,OR]\nRewriteCond %{QUERY_STRING} =PHP[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} [NC,OR]\nRewriteCond %{QUERY_STRING} (..\/|%2e%2e%2f|%2e%2e\/|..%2f|%2e.%2f|%2e.\/|.%2e%2f|.%2e\/) [NC,OR]\nRewriteCond %{QUERY_STRING} ftp: [NC,OR]\nRewriteCond %{QUERY_STRING} http: [NC,OR]\nRewriteCond %{QUERY_STRING} https: [NC,OR]\nRewriteCond %{QUERY_STRING} =|w| [NC,OR]\nRewriteCond %{QUERY_STRING} ^(.*)\/self\/(.*)$ [NC,OR]\nRewriteCond %{QUERY_STRING} ^(.*)cPath=http:\/\/(.*)$ [NC,OR]\nRewriteCond %{QUERY_STRING} (&lt;|%3C).*script.*(&gt;|%3E) [NC,OR]\nRewriteCond %{QUERY_STRING} (&lt;|%3C)([^s]*s)+cript.*(&gt;|%3E) [NC,OR]\nRewriteCond %{QUERY_STRING} (&lt;|%3C).*embed.*(&gt;|%3E) [NC,OR]\nRewriteCond %{QUERY_STRING} (&lt;|%3C)([^e]*e)+mbed.*(&gt;|%3E) [NC,OR]\nRewriteCond %{QUERY_STRING} (&lt;|%3C).*object.*(&gt;|%3E) [NC,OR]\nRewriteCond %{QUERY_STRING} (&lt;|%3C)([^o]*o)+bject.*(&gt;|%3E) [NC,OR]\nRewriteCond %{QUERY_STRING} (&lt;|%3C).*iframe.*(&gt;|%3E) [NC,OR]\nRewriteCond %{QUERY_STRING} (&lt;|%3C)([^i]*i)+frame.*(&gt;|%3E) [NC,OR]\nRewriteCond %{QUERY_STRING} base64_encode.*(.*) [NC,OR]\nRewriteCond %{QUERY_STRING} base64_(en|de)code[^(]*([^)]*) [NC,OR]\nRewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]\nRewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2}) [OR]\nRewriteCond %{QUERY_STRING} ^.*((|)|&lt;|&gt;|%3c|%3e).* [NC,OR]\nRewriteCond %{QUERY_STRING} ^.*(x00|x04|x08|x0d|x1b|x20|x3c|x3e|x7f).* [NC,OR]\nRewriteCond %{QUERY_STRING} (NULL|OUTFILE|LOAD_FILE) [OR]\nRewriteCond %{QUERY_STRING} (.{1,}\/)+(motd|etc|bin) [NC,OR]\nRewriteCond %{QUERY_STRING} (localhost|loopback|127.0.0.1) [NC,OR]\nRewriteCond %{QUERY_STRING} (&lt;|&gt;|&#39;|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]\nRewriteCond %{QUERY_STRING} concat[^(]*( [NC,OR]\nRewriteCond %{QUERY_STRING} union([^s]*s)+elect [NC,OR]\nRewriteCond %{QUERY_STRING} union([^a]*a)+ll([^s]*s)+elect [NC,OR]\nRewriteCond %{QUERY_STRING} -[sdcr].*(allow_url_include|allow_url_fopen|safe_mode|disable_functions|auto_prepend_file) [NC,OR]\nRewriteCond %{QUERY_STRING} (;|&lt;|&gt;|&#39;|&quot;|)|%0A|%0D|%22|%27|%3C|%3E|%00).*(\/*|union|select|insert|drop|delete|update|cast|create|char|convert|alter|declare|order|script|set|md5|benchmark|encode) [NC,OR]\nRewriteCond %{QUERY_STRING} (sp_executesql) [NC]\nRewriteCond %{HTTP_USER_AGENT} ^w3af.sourceforge.net [NC,OR]\nRewriteCond %{HTTP_USER_AGENT} dirbuster [NC,OR]\nRewriteCond %{HTTP_USER_AGENT} nikto [NC,OR]\nRewriteCond %{HTTP_USER_AGENT} SF [OR]\nRewriteCond %{HTTP_USER_AGENT} sqlmap [NC,OR]\nRewriteCond %{HTTP_USER_AGENT} fimap [NC,OR]\nRewriteCond %{HTTP_USER_AGENT} nessus [NC,OR]\nRewriteCond %{HTTP_USER_AGENT} whatweb [NC,OR]\nRewriteCond %{HTTP_USER_AGENT} Openvas [NC,OR]\nRewriteCond %{HTTP_USER_AGENT} jbrofuzz [NC,OR]\nRewriteCond %{HTTP_USER_AGENT} libwhisker [NC,OR]\nRewriteCond %{HTTP_USER_AGENT} webshag [NC,OR]\nRewriteCond %{HTTP:Acunetix-Product} ^WVS\nRewriteRule ^.* http:\/\/127.0.0.1\/ [R=301,L]\n&lt;\/IfModule&gt;\n&lt;FilesMatch &quot;^(wp-comments-post.phpwp-config.php|php.ini|php5.ini|readme.html|bb-config.php)&quot;&gt;\nOrder Allow,Deny\nDeny from 46.119.35.\nDeny from 46.119.45.\nDeny from 91.236.74.\nDeny from 93.182.147.\nDeny from 93.182.187.\nDeny from 94.27.72.\nDeny from 94.27.75.\nDeny from 94.27.76.\nDeny from 193.105.210.\nDeny from 195.43.128.\nDeny from 198.144.105.\nDeny from 199.15.234.\nDeny from 91.200.13.87.\nDeny from 49.74.155.215.\nDeny from 81.214.175.228.\nDeny from 78.178.240.58.\nDeny from 78.173.179.91.\nDeny from 82.200.168.83.\nDeny from 212.156.45.238.\nDeny from 78.178.243.76.\nDeny from 78.191.47.181.\nDeny from 78.187.238.107.\nDeny from 188.190.100.50.\n\nAllow from all\n&lt;\/FilesMatch&gt;\n\n# Enable GZIP\n&lt;ifmodule mod_deflate.c&gt;\nAddOutputFilterByType DEFLATE text\/text text\/html text\/plain text\/xml text\/css application\/x-j\u0430vascript application\/j\u0430vascript\nBrowserMatch ^Mozilla\/4 gzip-only-text\/html\nBrowserMatch ^Mozilla\/4.0[678] no-gzip\nBrowserMatch bMSIE !no-gzip !gzip-only-text\/html\n&lt;\/ifmodule&gt;\n# Expires Headers - 2678400s = 31 days\n&lt;ifmodule mod_expires.c&gt;\nHeader set Connection keep-alive\nExpiresActive On\nExpiresDefault &quot;access plus 2678400 seconds&quot;\nExpiresByType text\/html &quot;access plus 7200 seconds&quot;\nExpiresByType image\/gif &quot;access plus 2678400 seconds&quot;\nExpiresByType image\/jpeg &quot;access plus 2678400 seconds&quot;\nExpiresByType image\/png &quot;access plus 2678400 seconds&quot;\nExpiresByType text\/css &quot;access plus 750000 seconds&quot;\nExpiresByType text\/j\u0430vascript &quot;access plus 2678400 seconds&quot;\nExpiresByType application\/x-j\u0430vascript &quot;access plus 2678400 seconds&quot;\n&lt;\/ifmodule&gt;\n# Cache Headers\n&lt;ifmodule mod_headers.c&gt;\n# Cache specified files for 31 days\n&lt;filesmatch &quot;.(ico|flv|jpg|jpeg|png|gif|css|swf)$&quot;&gt;\nHeader set Cache-Control &quot;max-age=2678400, public&quot;\n&lt;\/filesmatch&gt;\n# Cache HTML files for a couple hours\n&lt;filesmatch &quot;.(html|htm)$&quot;&gt;\nHeader set Cache-Control &quot;max-age=7200, private, must-revalidate&quot;\n&lt;\/filesmatch&gt;\n# Cache PDFs for a day\n&lt;filesmatch &quot;.(pdf)$&quot;&gt;\nHeader set Cache-Control &quot;max-age=86400, public&quot;\n&lt;\/filesmatch&gt;\n# Cache j\u0430vascripts for 31 days\n&lt;filesmatch &quot;.(js)$&quot;&gt;\nHeader set Cache-Control &quot;max-age=2678400, private&quot;\norder deny,allow\ndeny from all\norder allow,deny\ndeny from all\n# END WordPress<\/code><\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Try your site yourself with the current 2020 htaccess content, you will agree when you see the speed difference.<\/p>","protected":false},"author":1,"featured_media":4284,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[169,165,164,168,167,166,171,170],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/posts\/4216"}],"collection":[{"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/comments?post=4216"}],"version-history":[{"count":3,"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/posts\/4216\/revisions"}],"predecessor-version":[{"id":4282,"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/posts\/4216\/revisions\/4282"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/media\/4284"}],"wp:attachment":[{"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/media?parent=4216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/categories?post=4216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/tags?post=4216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}