Don't like ads? Go Ad-Free Today

Apache .htaccess Formatter & Validator

Developer
ADVERTISEMENT · REMOVE?
RewriteRule Flag Reference
FlagNameDescription
LLastStop processing further rules
R[=code]RedirectIssue an external redirect (default 302)
NCNo CaseCase-insensitive pattern matching
QSAQuery String AppendAppend query string to substitution URL
NENo EscapeDon't escape special characters in output
PTPass ThroughPass to next handler (useful with Alias)
PProxyForce proxy request for substitution
FForbiddenReturn 403 Forbidden response
GGoneReturn 410 Gone response
CChainChain current rule with the next rule
COCookieSet a cookie
EEnvSet an environment variable
HHandlerForce a content handler
NNextRe-run rules from the start
NSNo SubrequestSkip rule for internal sub-requests
SSkipSkip the next N rules
TTypeForce MIME type
BEscape BackreferencesEscape non-alphanumeric backreference chars
DPIDiscard Path InfoDiscard PATH_INFO from rewritten URI
ENDEndStop processing and don't apply more rules

RewriteCond sets a condition that must match before the next RewriteRule is applied. Syntax: RewriteCond TestString CondPattern [flags]. Multiple RewriteCond lines before a RewriteRule are combined with AND logic by default.

Common Snippets
ADVERTISEMENT · REMOVE?

Guide

Apache .htaccess Formatter & Validator

Apache .htaccess Formatter & Validator

Format and validate Apache .htaccess files with proper block indentation, syntax checking, and common error detection. Paste your .htaccess content and instantly see consistently formatted output with validation warnings for unclosed blocks, mismatched tags, invalid RewriteRule flags, and more. Includes common snippet templates and a RewriteRule flag reference.

How to Use

Paste your .htaccess content into the input area. The formatter processes it instantly — indenting block directives (IfModule, Directory, Files, etc.), normalizing comments, and validating syntax. Configure indent style (2 spaces, 4 spaces, or tabs), comment normalization, and blank line handling. Copy the formatted output or download it as an .htaccess file. Use the common snippets section to quickly insert standard configurations.

Features

  • Block Indentation — Automatically indents nested directives inside IfModule, Directory, Files, FilesMatch, Location, LocationMatch, Limit, VirtualHost, Proxy, RequireAll, RequireAny, and other Apache block directives.
  • Syntax Validation — Real-time error detection: unclosed blocks, extra closing tags, mismatched block types, missing RewriteEngine directive, invalid RewriteRule flags. Color-coded with line numbers.
  • RewriteRule Flag Checking — Validates flags in RewriteRule directives against the full list of known Apache flags (L, R, NC, QSA, NE, PT, P, F, G, C, CO, E, H, N, NS, S, T, B, DPI, END).
  • Comment Handling — Preserves all comments with optional normalization (ensures space after #). Inline comments maintained in position.
  • Formatting Options — Configurable indent style (2 spaces, 4 spaces, tab), comment normalization toggle, blank line collapsing.
  • Common Snippets — Quick-insert templates: force HTTPS, trailing slash handling, custom error pages, IP blocking, GZIP compression, cache headers, directory listing prevention.
  • RewriteRule Reference — Collapsible reference table with all RewriteRule flags and their descriptions, plus RewriteCond/RewriteRule syntax guide.
  • Export — Copy formatted output or download as .htaccess file.

Validation Checks

Block matching: Every opening block tag must have a corresponding closing tag of the same type. RewriteEngine: Warns if RewriteRule or RewriteCond directives are used without RewriteEngine On. Flag validation: Checks RewriteRule flags against known Apache mod_rewrite flags. Duplicate detection: Alerts when the same directive appears multiple times (may be intentional but worth reviewing).

ADVERTISEMENT · REMOVE?

What is an .htaccess file?

An .htaccess (hypertext access) file is a directory-level configuration file for Apache HTTP Server. It allows you to override server configuration on a per-directory basis without editing the main httpd.conf. Common uses include URL rewriting (pretty URLs, redirects), access control (password protection, IP blocking), custom error pages, MIME type configuration, and caching headers. The file is named .htaccess (with a leading dot) and is placed in the directory you want to configure.

What are the most common RewriteRule flags?

The most frequently used flags are: [L] (Last — stop processing rules), [R=301] (Redirect — send HTTP redirect, 301 for permanent), [NC] (No Case — case-insensitive matching), [QSA] (Query String Append — preserve existing query string), [NE] (No Escape — don’t encode special characters), [P] (Proxy — handle via mod_proxy), [F] (Forbidden — return 403), and [END] (like L but also prevents further .htaccess processing in subdirectories). Multiple flags are combined with commas: [L,R=301,NC].

Why does my .htaccess redirect loop?

Redirect loops usually happen when a RewriteRule matches its own output. For example, redirecting all requests to HTTPS will loop if the rule doesn’t check whether the request is already HTTPS. Always add a RewriteCond before redirect rules: RewriteCond %{HTTPS} off (for HTTPS redirects) or RewriteCond %{REQUEST_URI} !^/target (to exclude the target path). Also check for conflicting rules — multiple redirect rules can create circular references. The [L] flag helps by stopping rule processing after a match.

Is my .htaccess content sent to a server?

No — all formatting and validation happens in your browser using JavaScript. Your .htaccess content never leaves your device. This is important because .htaccess files can contain sensitive configuration: access control rules, internal paths, IP addresses, and security settings. All processing runs entirely client-side with no API calls or data storage.

Want To enjoy an ad-free experience? Go Ad-Free Today

Install Our Extensions

Add IO tools to your favorite browser for instant access and faster searching

Add to Chrome Extension Add to Edge Extension Add to Firefox Extension Add to Opera Extension

Scoreboard Has Arrived!

Scoreboard is a fun way to keep track of your games, all data is stored in your browser. More features are coming soon!

ADVERTISEMENT · REMOVE?
ADVERTISEMENT · REMOVE?
ADVERTISEMENT · REMOVE?

News Corner w/ Tech Highlights

Get Involved

Help us continue providing valuable free tools

Buy me a coffee
ADVERTISEMENT · REMOVE?