📄
Webhosting

Htaccess file: what it is and what you can do with it

📅 7 Oktober 2026 ✏️ 7 Oktober 2026 ⏱ 5 min leestijd

.htaccess explained: what this file does, what you use it for, and how to safely modify it on your web hosting.

The .htaccess file is a configuration file that applies rules per directory on Apache and LiteSpeed servers, without you having to modify the server’s main configuration. You use it, for example, to redirect URLs, password-protect folders, force HTTPS, or customize error pages. In this article you’ll read exactly what the file does, how to safely modify it, and what to do if your website shows an error message after a change.

What is a .htaccess file?

A .htaccess file is a plain text file located in a folder on your web server that gives instructions to the server about how it should behave in that folder (and subfolders). The name starts with a dot, which makes the file hidden by default on most systems. You use it among other things for:

  • Setting up redirects, for example from an old URL to a new one
  • Automatically redirecting HTTP to HTTPS
  • Protecting folders with a username and password
  • Setting up custom error pages (such as a 404 page)
  • Blocking access for specific IP addresses
  • Making permalinks work with CMS systems like WordPress

The big advantage is that changes take effect immediately as soon as you save the file, without the web server needing to be restarted.

Visitor→.htaccess→Website

The .htaccess file filters and directs traffic before it reaches the website.

Where to find the file

The .htaccess file is usually located in the root folder of your website, next to folders like public_html or httpdocs. Because the file is hidden, you need to enable the ’show hidden files‘ option in your FTP program or file manager. If you use Plesk, you can find it via Files in the hosting panel, where you can also directly show hidden files and edit the file online. If the file doesn’t exist yet in the folder, you can simply create it yourself as an empty text file with exactly that name.

💡 Tip: Always make a copy of your existing .htaccess file first before making changes. This way you can revert to the previous version with one click if something goes wrong.

Commonly used rules in .htaccess

Below are a few examples you’ll often need. Note: rules are case-sensitive and must be exactly correct, otherwise the rule won’t work or will cause an error.

1

Forcing HTTPS

With a few lines you ensure that visitors who arrive via http are automatically redirected to the secure https version of your site. This is especially useful if you’ve just installed an SSL certificate but old links still point to http.

2

Redirecting an old page

With a ‚Redirect 301‘ rule you send visitors and search engines from a deleted page to the correct new location, so you don’t lose visitors or SEO value.

3

Protecting a folder

By adding rules that refer to a separate password file, the server asks for a username and password before a folder is accessible. Useful for a test environment that shouldn’t be public yet.

4

Blocking IP addresses

You can deny access to your website for specific IP addresses, for example if you repeatedly see unwanted traffic from a certain address.

If you use WordPress, the CMS automatically manages part of the .htaccess rules for permalinks. If you modify this manually, make sure you work outside the markers # BEGIN WordPress and # END WordPress, so that WordPress doesn’t overwrite your own rules.

Fixing errors

A small syntax error in your .htaccess file can immediately lead to a 500 Internal Server Error on your entire website. This often happens because a bracket, dot, or comma is missing, or because a module you’re calling isn’t available on the server. Proceed as follows to resolve this:

  • Open the file via Plesk or FTP and check the most recently added lines
  • Temporarily rename the file (for example to .htaccess_old) to check if the site works again
  • If the site works again, add the lines back one by one until you find the faulty line
  • Restore the previously made backup if you can’t find the error quickly

If you’re unsure whether a specific rule is supported at all on your hosting environment, contact us via the knowledge base and support before making major changes to an active website.

Frequently asked questions

Does .htaccess also work on LiteSpeed servers?

Yes, LiteSpeed is built to be compatible with Apache configuration, including .htaccess files. Most standard rules work without modifications as a result.

Can I have multiple .htaccess files?

Yes, you can place your own .htaccess file in each subfolder. Rules in a subfolder then apply in addition to (or as a replacement for) the rules in the root folder.

Can I use .htaccess to make my site faster?

You can, for example, configure browser caching and compression via .htaccess, which can contribute to a faster website alongside other optimizations.

Why isn’t my .htaccess change working?

Check whether the correct module is active on the server, whether there’s no typo in the rule, and whether the file is actually located in the correct folder.

Conclusion

The .htaccess file is a powerful tool for configuring your website at the folder level, from redirects to security. Work carefully with it, always make a backup before changing anything, and test changes immediately after saving. If you manage your site via Plesk on web hosting from Tandata, you can easily and safely edit the file within the file manager.

View web hosting →

Was dit artikel nuttig?