{"id":112465,"date":"2023-01-18T17:16:53","date_gmt":"2023-01-18T17:16:53","guid":{"rendered":"https:\/\/wpsimplefix.com\/?p=112465"},"modified":"2026-09-24T17:42:06","modified_gmt":"2026-09-24T17:42:06","slug":"the-htaccess-file","status":"publish","type":"post","link":"https:\/\/chkserv.com\/blog\/the-htaccess-file\/","title":{"rendered":"Managing The htaccess file"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">WordPress is <a href=\"https:\/\/wordpress.org\/about\/security\/\" target=\"_blank\" rel=\"noopener\">a secure platform<\/a> out of the box, but keeping your site safe should be your highest priority. You can use the file called .htaccess to harden your site security.&nbsp;The configuration file is used for Apache servers, it&#8217;s powerful, and you can do a lot with it, like boost performance, secure your site, create redirects or even deny access to parts of your site.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you place code in the Htaccess ( HyperText Access ) file incorrectly, it can make your whole site give a bunch of errors and be inaccessible, until fixed. So only go touching this file if you know what you\u2019re doing.&nbsp;You will find this file ( Most likely hidden ) in the root directory of your website. The dot at the start makes the file hidden. Editing it is easy, just know what you\u2019re putting in the file is safe.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use the text editor of your choice to open the file. You&#8217;ll see the following default data if the file hasn&#8217;t been edited before. Between the # BEGIN and # # END tags, nothing should be changed or added.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" src=\"https:\/\/chkserv.com\/blog\/wp-content\/uploads\/2023\/01\/wp-htaccess-file-0123.png\" alt=\"htaccess-file\" style=\"aspect-ratio:1.9559902200488997;width:800px;height:auto\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Some Examples<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Deny access to parts of your site:\n<ul class=\"wp-block-list\">\n<li><em>Make sure to change <\/em><em><strong>file-name.php <\/strong><\/em><em>to the correct name<\/em> on line 1<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-1\"><code readonly=\"true\">&lt;Files \/file-name.php><br>Order Allow,Deny<br>Deny from All<br>&lt;\/Files><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Disable Directory Browsing<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-2\"><code readonly=\"true\">Options All -Indexes<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Force your site to load HTTPS<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-3\"><code readonly=\"true\">HTTPSRewriteEngine On<br>RewriteCond %{HTTPS} !=on<br>RewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} [L,R=30<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Prevent Image Hot linking.\n<ul class=\"wp-block-list\">\n<li><em>Make sure to change <\/em><em>your-website.com <\/em><em>to your actual website domain on line 3.<\/em><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-4\"><code readonly=\"true\">\/* Prevent image hotlinking *\/<br>RewriteCond %{HTTP_REFERER} !^$<br>RewriteCond %{HTTP_REFERER} !^http(s):\/\/(www.)your-website.com\/.*$ [NC]<br>RewriteRule .(gif|jpg|jpeg|bmp|png)$ - [F]<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Redirect URLs<\/li>\n\n\n\n<li>Cache Control<\/li>\n\n\n\n<li>Prevent script injection attacks<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The <i>.htaccess<\/i> file provides flexibility for controlling how your web server behaves. Editing your <i>htaccess<\/i> file is just one way to improve your site\u2019s security.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress is a secure platform out of the box, but keeping your site safe should be your highest priority. You can use the file called .htaccess to harden your site security.&nbsp;The configuration file is used for Apache servers, it&#8217;s powerful, and you can do a lot with it, like boost performance, secure your site, create [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":121200,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[8,9,10,11,4],"class_list":["post-112465","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","tag-edit","tag-file","tag-htaccess","tag-modify","tag-secure"],"_links":{"self":[{"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/posts\/112465","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/comments?post=112465"}],"version-history":[{"count":3,"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/posts\/112465\/revisions"}],"predecessor-version":[{"id":136721,"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/posts\/112465\/revisions\/136721"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/media\/121200"}],"wp:attachment":[{"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/media?parent=112465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/categories?post=112465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/tags?post=112465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}