{"id":20270,"date":"2026-07-24T14:38:48","date_gmt":"2026-07-24T12:38:48","guid":{"rendered":"https:\/\/surver.nl\/?post_type=kennisbank&#038;p=20270"},"modified":"2026-07-24T14:42:00","modified_gmt":"2026-07-24T12:42:00","slug":"wordpress-htaccess-file-explanation-and-common-rules","status":"publish","type":"kennisbank","link":"https:\/\/surver.nl\/en\/kennisbank\/wordpress-htaccess-bestand-uitleg-en-veelgebruikte-regels\/","title":{"rendered":"WordPress .htaccess File: Explanation and Common Rules"},"content":{"rendered":"<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"600\" src=\"https:\/\/surver.nl\/wp-content\/uploads\/2026\/07\/wp-htaccess.jpg\" alt=\"wp.htaccess\" class=\"wp-image-20271\" srcset=\"https:\/\/surver.nl\/wp-content\/uploads\/2026\/07\/wp-htaccess.jpg 1024w, https:\/\/surver.nl\/wp-content\/uploads\/2026\/07\/wp-htaccess-300x176.jpg 300w, https:\/\/surver.nl\/wp-content\/uploads\/2026\/07\/wp-htaccess-768x450.jpg 768w, https:\/\/surver.nl\/wp-content\/uploads\/2026\/07\/wp-htaccess-18x12.jpg 18w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">A tutorial says you need to add a line to your .htaccess file, but you can\u2019t find the file anywhere. Or worse: you just pasted something into it, and now your entire site is displaying a \u201c500 Internal Server Error\u201d message. Both situations involve the same file, and both can be quickly resolved once you understand what .htaccess actually is: a small configuration file that allows you to give instructions to the web server before WordPress even starts running. It\u2019s a powerful tool, but the downside is that a single incorrect line can take your entire site down. In this article, we\u2019ll explain what the file does, what kinds of rules you\u2019ll encounter in practice, and how to fix an error in under a minute.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What .htaccess is and where it is located<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The .htaccess file is located in the root directory of your WordPress installation, next to wp-config.php. The period at the beginning of the name means it\u2019s a hidden file: if you don\u2019t see it in your file manager or FTP program (file access to your hosting), enable the \u201cshow hidden files\u201d option. The rules in the file are executed by the web server itself with every request to your site. That\u2019s why .htaccess can do things WordPress can\u2019t: redirect traffic, restrict access to folders, and control caching behavior before a single line of WordPress code even runs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At Surver: Our LiteSpeed web servers fully support .htaccess rules, so everything in this article works on our hosting exactly as described.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What WordPress Adds Itself<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you open the file on a standard site, you\u2019ll see a block that starts with # BEGIN WordPress and ends with # END WordPress. These lines ensure that your clean URLs (permalinks) work: they forward every request to WordPress, which then finds the correct page. There are two things you need to know about this. First: stay out of this block. WordPress rewrites it itself when necessary\u2014for example, when you save the permalink settings\u2014and will overwrite anything you\u2019ve put inside it. So always place your own code outside this block, above it. Second, this explains a classic problem: if you get a 404 error on all pages except the homepage, this block is either missing or corrupted. The fix is surprisingly simple: in the dashboard, go to Settings, then Permalinks, and click Save Changes. WordPress will then rewrite the block.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>The rules you'll encounter in practice<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Redirects<\/strong> The most common use case is permanently redirecting visitors from an old address to a new one. A single redirected page looks like this: Redirect 301 \/old-page\/ https:\/\/jouwdomein.nl\/nieuwe-pagina\/. For individual pages, a redirect plugin is actually more user-friendly; .htaccess is primarily the right place for structural redirects, such as all traffic from www to non-www or from http to https.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Security Rules<\/strong> Protect sensitive files. For example, a commonly used rule blocks external access to wp-config.php or xmlrpc.php, and you can use it to restrict access to the login page to specific IP addresses. Many security plugins automatically generate these types of rules for you; you can identify their blocks by the comment lines containing the plugin name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Caching and Compression Rules<\/strong> They tell browsers how long they can keep files and enable compression so that pages are smaller when they\u2019re sent over the network. The same applies here: caching plugins like LiteSpeed Cache write these blocks into .htaccess themselves. If you see a block like this, leave it alone; it\u2019s part of the plugin.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Our advice on all of this: only add rules that you understand, and let plugins manage their own blocks. The .htaccess file for the average site is mostly written by WordPress and plugins, and that\u2019s perfectly fine.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Safe Editing: The Process<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Download the current .htaccess file to your computer as a backup. This is the most important step of all: with this copy, you can undo any mistake in just one minute.<\/li>\n\n\n\n<li>Open the file in your file manager's editor or in a Notepad-style editor; never open it in a word processor like Word (which adds invisible formatting that the server cannot interpret).<\/li>\n\n\n\n<li>Place your new line above the WordPress block and add a comment line (a line that starts with #) explaining what it does and when you added it.<\/li>\n\n\n\n<li>Save and test your site right away: the homepage, an inner page, and the dashboard.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">If you want a comprehensive safety net in addition to this file copy, make sure you have a recent backup of your site; you can read about how to set that up in our <a href=\"https:\/\/surver.nl\/en\/knowledge-base\/wordpress-backup-en-migratie-de-complete-gids\/\">A Complete Guide to WordPress Backups and Migration<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Is your site down after a change? Here's how to roll it back<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you see a 500 error or a blank page after saving, there\u2019s a syntax error in the file: the server doesn\u2019t understand one of the lines. Because .htaccess runs before WordPress, such an error brings everything down, including your dashboard. To fix this, you\u2019ll always need to edit the files: use the file manager or FTP to restore your backup, or delete the line you just added. Your site will be back up immediately. If you didn\u2019t create a backup, temporarily rename the file to .htaccess_broken and resave the permalinks in the dashboard; WordPress will then generate a fresh, working file, after which you can add your own rules one by one.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At Surver: Thanks to the daily automatic backups included with our managed plans, we can also restore yesterday\u2019s complete file for you. And if you\u2019re unsure about a line of code that a tutorial asks you to add, feel free to run it by our support team first; we\u2019re available seven days a week.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Is this part of your job responsibilities?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Honest answer: For most site owners, .htaccess is a file you should be familiar with, not one you need to edit every week. The times when you really need it are for structural redirects and fixing a broken permalink block; leave the rest to plugins and your web developer. If you\u2019ve just started your site, focus your energy first on the visible side using our <a href=\"https:\/\/surver.nl\/en\/knowledge-base\/een-website-maken-met-wordpress-de-startgids-voor-beginners\/\">A Beginner's Guide to Creating a Website with WordPress<\/a>. And if you want to know what other technical aspects are involved in managing a website, you'll find a complete overview in our <a href=\"https:\/\/surver.nl\/en\/knowledge-base\/wordpress-management-the-complete-guide-for-beginners-and-advanced-users\/\">A Complete Guide to WordPress Management<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Een tutorial zegt dat je een regel moet toevoegen aan je .htaccess-bestand, maar je kunt het bestand nergens vinden. Of erger: je hebt er net iets in geplakt en nu toont je hele site een foutmelding met &#8220;500 Internal Server Error&#8221;. Beide situaties horen bij hetzelfde bestand, en beide zijn snel opgelost als je begrijpt [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"template":"","meta":{"_acf_changed":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}}},"kennisbank_categorieen":[62],"class_list":["post-20270","kennisbank","type-kennisbank","status-publish","hentry","kennisbank_categorieen-wordpress"],"acf":[],"_links":{"self":[{"href":"https:\/\/surver.nl\/en\/wp-json\/wp\/v2\/kennisbank\/20270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/surver.nl\/en\/wp-json\/wp\/v2\/kennisbank"}],"about":[{"href":"https:\/\/surver.nl\/en\/wp-json\/wp\/v2\/types\/kennisbank"}],"author":[{"embeddable":true,"href":"https:\/\/surver.nl\/en\/wp-json\/wp\/v2\/users\/2"}],"wp:attachment":[{"href":"https:\/\/surver.nl\/en\/wp-json\/wp\/v2\/media?parent=20270"}],"wp:term":[{"taxonomy":"kennisbank_categorieen","embeddable":true,"href":"https:\/\/surver.nl\/en\/wp-json\/wp\/v2\/kennisbank_categorieen?post=20270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}