---
title: ".htaccess"
description: "The .htaccess file configures the Apache server per directory: redirects, pretty URLs, password protection and headers. Learn its syntax and common uses."
url: "https://nodea.io/en/glossary/htaccess"
lang: "en"
updated: "2026-07-13"
---

# .htaccess

> .htaccess is an Apache configuration file that lets you change server behavior at the level of a single directory — without access to the main config and without restarting the service. It is a core tool on shared hosting.

**.htaccess** is a configuration file used by the [Apache](https://nodea.io/en/glossary/apache) server (and the compatible LiteSpeed) that lets you override server settings within the directory it sits in and all of its subdirectories. Its biggest advantage is that changes take effect immediately, with no service restart and no access to the main configuration — so on shared hosting every customer can control their own site's behavior even though the provider manages the server.

## How .htaccess works

On every request, Apache checks whether the path to the requested file contains any .htaccess files and applies the directives inside them. Rules are written in a simple text syntax, and the most commonly used component is the *mod\_rewrite* module, which rewrites and redirects addresses. This flexibility has a cost: checking these files on every request adds more load than a central configuration, so under heavy traffic .htaccess is sometimes disabled in favor of rules in the main config.

## Practical application

Typical tasks handled by .htaccess include:

- **Redirects** — such as a [301 redirect](https://nodea.io/en/glossary/301-redirect) from an old address to a new one, or forcing the www or non-www version.
- **Pretty URLs** — hiding parameters and creating readable [URLs](https://nodea.io/en/glossary/friendly-url) that WordPress, PrestaShop and Joomla depend on.
- **Directory protection** — password protection (paired with an .htpasswd file) or blocking access by IP address.
- **Headers and performance** — setting security headers, gzip compression or browser caching.

A single syntax error can make the whole site return a 500 error, so it's wise to back up the file before editing. On a typical [hosting](https://nodea.io/en/glossary/hosting) account with a DirectAdmin panel, .htaccess is the main configuration tool available to the user.

### Why does the filename start with a dot?

On Unix-like systems, files beginning with a dot are hidden and don't appear in a default directory listing. The name stands for 'hypertext access', and the convention protects the config file from being accidentally displayed or deleted by a user.

### Does .htaccess work on Nginx?

No. The .htaccess file is a feature of Apache and compatible servers such as LiteSpeed. Nginx does not read these files — its redirect and access rules are defined centrally in the server configuration, which is more efficient but requires administrative access.

## Related

- [Apache](https://nodea.io/en/glossary/apache)
- [301 redirect](https://nodea.io/en/glossary/301-redirect)
- [Friendly URL](https://nodea.io/en/glossary/friendly-url)
- [ModSecurity](https://nodea.io/en/glossary/modsecurity)
- [Hosting](https://nodea.io/en/glossary/hosting)

---

Languages: [pl](https://nodea.pl/pl/slownik-pojec/htaccess.md)  
Site index: [llms.txt](https://nodea.io/en/llms.txt)
