.htaccess

What is a .htaccess file?

Apache web server config dropped into a directory — URL rewrites, password protection, redirects, and a thousand WordPress hacks.

Use caution
Type Code
By Apache Software Foundation
MIME text/plain

Drop any file to identify it

No upload. No signup. No sending your file halfway across the internet.
We tell you what it is, right here in your browser.

What is it

An .htaccess file is a directory-level Apache configuration file. Drop one into a folder on an Apache web server and it overrides the global config for that folder and everything beneath it. The single most common use is URL rewriting via mod_rewrite: pretty URLs like `/blog/my-post` getting silently mapped to `/index.php?post=my-post`. Almost every WordPress install has an .htaccess file at its root doing exactly this.

Beyond rewrites, .htaccess can password-protect directories (with .htpasswd), set custom error pages, redirect URLs, gzip-compress responses, set caching headers, block specific IP addresses, and force HTTPS. The syntax is Apache directives — `RewriteRule`, `Redirect`, `Header`, `AuthType` — one per line. Comments start with `#`. A misplaced character will return a 500 Internal Server Error for the entire directory, so test changes carefully and keep a backup.

The critical caveat: .htaccess is Apache-only. Nginx, Caddy, and IIS don't read it — those servers configure routing in their own central config files. Apache itself recommends putting directives in the main config (`httpd.conf`) when possible, because .htaccess is checked on every request and slightly slows things down. .htaccess exists primarily because shared hosting lets users configure their site without root access to the main config. If you control the server, the central config is faster.

Technical details
Full Name
.htaccess
MIME Type
text/plain
Developer
Apache Software Foundation
Magic Bytes
N/A
Safety
.htaccess requires caution. A single syntax error will break the entire directory with a 500 error. Always keep a backup before editing.
What opens it
Any text editor
FREE All
VS Code
FREE All
FAQ
Does .htaccess work with Nginx?
No. .htaccess is Apache-specific. Nginx uses its own config syntax in `nginx.conf` and `sites-available/`. If you're migrating from Apache to Nginx, the rewrite rules need to be rewritten — there are conversion tools online but check the result carefully.
Why doesn't my .htaccess file work?
Most common cause: AllowOverride is set to None in the main Apache config, which disables .htaccess entirely. Check `/etc/apache2/apache2.conf` for `AllowOverride All` on your directory. Also: .htaccess is hidden on macOS/Linux (leading dot), so make sure your editor or FTP client is showing hidden files.
Related formats