.htaccess Tester

Test Apache .htaccess rewrite rules, conditions and redirects against any URL — and see exactly…

REWRITERULE + REWRITECOND REDIRECT DIRECTIVES FLAG SUPPORT 100% PRIVATE
Free Professional Tool | No Registration Required | Updated: January 2026
AI-GENERATED TOOL

Note: This .htaccess Tester was created with the help of AI. It simulates the most common Apache mod_rewrite behavior — RewriteRule, RewriteCond, Redirect and their flags — entirely in your browser. It does not replace testing on a real Apache server. File-system tests like -f / -d cannot be evaluated client-side and are marked as unknown.

Debug Apache Rules Without a Server

Trace redirects, matched conditions and rewrite targets step by step — before you deploy.

Step-by-step Trace Flag Support Presets Library

.htaccess Content

Test Request

Result

Click Run Test to simulate the .htaccess against the URL above.

Ready-to-Use .htaccess Presets

Click any preset to load its rules into the tester, then hit Run Test to see the behavior.

Quick Reference

Common RewriteRule Flags

FlagMeaning
[R] / [R=301]Redirect (302 by default, or the given status)
[L]Last rule — stop processing further rules
[NC]No Case — case-insensitive matching
[QSA]Query String Append — keep original query with new one
[F]Forbidden — return 403
[G]Gone — return 410
[P]Proxy — pass through mod_proxy
[NE]No Escape — don't escape special chars in output
[PT]Pass Through — hand rewritten URL to next handler
[C]Chain — link this rule with the next one
[B]Escape backreferences before applying substitution
[E=VAR:val]Set environment variable
[CO=NAME:val:domain]Set cookie
[NS]No Subrequest
[OR]OR with next condition (used on RewriteCond)
[S=n]Skip next n rules

Common RewriteCond Variables

VariableValue
%{HTTP_HOST}The hostname from the request (e.g. www.example.com)
%{REQUEST_URI}The path + query string (e.g. /about?id=5)
%{QUERY_STRING}Everything after the ? in the URL
%{REQUEST_METHOD}GET, POST, HEAD, etc.
%{HTTP_USER_AGENT}The User-Agent header
%{HTTP_REFERER}The Referer header
%{HTTPS}on or off
%{SERVER_PORT}80, 443, 8080, etc.
%{REMOTE_ADDR}Client IP address
%{REQUEST_FILENAME}Full filesystem path to the requested file
%{DOCUMENT_ROOT}The web server's document root
%{TIME_YEAR}Current year
%{TIME_MON}, %{TIME_DAY}Current month / day

Useful RewriteCond Patterns

PatternWhat it does
-fTest string is an existing file
-dTest string is an existing directory
-sTest string is a non-empty file
-lTest string is a symbolic link
!^patternNegated match — true when the regex does NOT match
^www\.Matches hosts starting with "www."
^.*\.php$Matches URIs ending in ".php"
^blog/Matches URIs starting with "/blog/" (path without leading slash)

Complete .htaccess Guide

What Is .htaccess?

.htaccess (Hypertext Access) is a per-directory Apache configuration file that lets you override server settings without editing the main httpd.conf. It's most commonly used for URL rewriting, redirects, access control and security headers.

The name starts with a dot, so on Unix-like systems it's hidden by default. In Apache's config, the directive AllowOverride controls whether .htaccess files are honored — often set to All on shared hosting and None on managed servers.

RewriteRule Anatomy

RewriteRule Pattern Substitution [Flags]
  • Pattern: a regular expression matched against the URL path without the leading slash.
  • Substitution: the target path or URL, with $1, $2, … backreferences from the pattern.
  • Flags: modifiers in [square brackets] — e.g. [R=301,L] for a permanent redirect + stop processing.

RewriteCond Anatomy

RewriteCond TestString CondPattern [Flags]

Applies to the next RewriteRule. Multiple RewriteCond lines above a rule are ANDed together by default, or ORed if you append [OR].

Path-Matching Rules in .htaccess

The URL matched by a RewriteRule in .htaccess does not include the leading slash. So for a request to /blog/post-1 at the web root, the pattern matches against blog/post-1. If your pattern starts with ^/, it will never match in .htaccess context (that syntax is for VirtualHost context).

Common Pitfalls

  1. Redirect loops: the HTTPS redirect rule matching the HTTPS request itself. Fix with RewriteCond %{HTTPS} off.
  2. Missing [L] flag: the next rule overwrites your substitution.
  3. Missing RewriteEngine On: rules silently do nothing.
  4. Forgetting that files/directories are checked first: use -f and -d conditions to skip rewrites for real files.
  5. Case sensitivity: URL paths are case-sensitive — add [NC] if you need case-insensitive matching.
  6. Query string loss: a rule without [QSA] drops the original query string by default.

Debugging Tips

  • Enable rewrite logging on the server: LogLevel alert rewrite:trace3.
  • Test each rule in isolation before layering them.
  • Use this tester to visualize what happens — but always verify on a staging Apache before pushing to production.

⚠️ AI-Generated Tool Notice: This tester was built with AI assistance. It simulates the most common subset of mod_rewrite behavior — but Apache is complex. Edge cases involving [P], [C], [PT], [NS], internal sub-requests and per-directory contexts are not fully simulated. Always verify critical redirects on a real staging server.

Frequently Asked Questions

No. It's a simulator written in JavaScript that parses your .htaccess rules and evaluates them against a virtual request. It handles RewriteRule, RewriteCond, common flags and variables, but it does not execute real Apache. Use it to catch obvious mistakes quickly, not as a substitute for real-server tests.

These conditions test the server's actual file system, which a browser can't access. The tester marks them as unknown and treats them as true by default (matching the common expectation that a real file exists). To test the "file doesn't exist" branch, temporarily replace -f with !-f and run again.

You've hit a redirect loop — a rule keeps matching its own output. Classic examples: an HTTPS redirect that also fires on HTTPS requests, or a www redirect missing the !^www\. condition. Add the appropriate RewriteCond to break the loop.

No. Everything runs 100% client-side. Your rules and test URL never leave your browser — no network requests, no analytics on your input.

Yes — the standard WordPress .htaccess is included in the Presets Library. Load it and test URLs like https://example.com/my-post/ to see how the front controller rewrite works.

Ready to Test Your Rules?

Paste your .htaccess, enter a URL, and see exactly what happens — instantly and privately.

Updated: January 2026 | Free for Commercial Use | 100% Client-Side Processing

Why Choose Our .htaccess Tester?

Step-by-Step Trace

See exactly which rule matched, which conditions passed, and what the URL became.

Redirect Chain

Visualise multiple hops and detect redirect loops before they hit production.

Preset Library

Load battle-tested snippets — HTTPS, www, WordPress, security — in one click.

100% Private

Nothing leaves your browser. No uploads, no logging, no analytics on your rules.

More SEO Tools