htaccess Rule Simulator

← All AI-created software

This is AI-generated (aka vibe-coded) software. It is specific to my needs and my system and may not work for you or yours. Support is limited, but if you report a bug I'll certainly look into it. The code is provided in the zip file for you to review should you choose.
⬇️ Download htaccess Rule Simulator.zip563.4 KBLast Updated: November 28, 2026Python

Shows what Apache would do with each URL under your .htaccess file, without sending a single request to your site: which URLs a firewall rule blocks, which are redirected and where to, which are rewritten to another page, and the error page a visitor would see. Use it before uploading a new .htaccess, to check that your real pages still work, your redirects land where you meant, and the probes you expect to be blocked are. Write down what each URL should get, and every run checks it for you.

Main window of htaccess Rule Simulator, with 27 URLs of a sample WordPress site simulated and checked, and below the table the steps of a chain of redirects beside the rule in the .htaccess
On this page

Features

  • Simulates a single URL, a TXT or CSV list of URLs, a sitemap (indexes followed), or every file in a local folder
  • Follows the whole .htaccess in order: RewriteRule and RewriteCond (with their flags), Redirect and RedirectMatch, ErrorDocument, RewriteBase and DirectoryIndex, round after round as Apache does
  • Says for each URL whether it is denied, redirected, rewritten, served as asked or an error, with the rule that decided, where it goes, the error page shown, and every step on the way
  • Follows redirects to the end, as a browser does, and flags chains, loops and redirects that end in an error
  • Checks each URL against the result you expect for it (DENIED, REDIRECTED 301 to a page), with a pass or fail
  • Runs each error page through the rules too, as Apache does, and says when a rule blocks the error page itself
  • Shows the rule that decided a URL in place in the .htaccess, and lists the rules no URL triggered
  • Tries each URL with a list of user agents (browsers, search engine and AI crawlers, social preview bots, tools, security scanners) to show which ones your rules catch and which slip through, or block what they shouldn’t
  • Sees each URL the way Apache does: the path decoded and cleaned up, and requests Apache refuses outright reported
  • With a copy of your site’s files, answers the rules’ file tests and finds missing pages and folders
  • A results table that sorts by any column and filters by a right-click on its heading
  • An optional CSV file of every result, ready for Excel (off unless you ask for it)
  • A console mode for scripts, with the same options

Usage

Needs Python 3.8 or later. The window needs Tkinter (python.org installers include it; on Debian and Ubuntu, sudo apt install python3-tk). Nothing else is needed; on Linux and macOS, Pillow (pip install pillow) gives the window the app’s own icon instead of Tk’s.

python htaccess-rule-simulator.py

Simulating URLs

Choose the .htaccess file at the top (type its path or click Browse…), then fill in one or more of the four sources of URLs below it.
They all stay filled in, and the round button beside each one picks the source a run uses; clicking in a source’s field or its Browse… picks it too. Click Simulate (or press F5, Ctrl+R, or Enter in a field):

  • Single URL: one URL, with its query string, as a visitor would request it.
  • URL list: a TXT file with one URL per line (lines starting with # are skipped), or a CSV file with a column of URLs, url unless you name another in CSV column. Each URL can say what it should get (see Checking expected results).
  • Sitemap: the address of an XML sitemap or sitemap index. Its sitemaps are fetched too; one that can’t be read is listed under Rules as a warning.
  • Local folder under a base URL: a base URL and a folder on your computer. Each file’s path, starting with the folder’s own name, is added to the base URL: images/2026/bed.jpg under https://www.example.com becomes https://www.example.com/images/2026/bed.jpg. This works with Cryptomator and other virtual drives.

Under Server, two optional fields:

  • Site folder: a copy of your site’s files (the folder the .htaccess sits in). With it, conditions such as RewriteCond %{REQUEST_FILENAME} !-f are answered, a folder asked for without its slash is redirected to it, a folder’s index file is found, and a missing page is a 404. Without it, a rule that tests files gives NOT TESTED, and a URL nothing changes is listed as served as asked.
  • User agent: the browser the rules see. Blank means Chrome on Windows; enter curl/8.5 or a bot’s name to see what your rules do with it.
  • Test each URL with the user agents checked in the list: see Testing user agents.

The fields, the source and the window’s layout are remembered for next time.

Reading the results

Each URL gets one of seven results, the ones needing a look first:

  • DENIED: a rule blocks it: [F] (403 Forbidden), [G] or a Redirect gone (410 Gone), or another error status.
  • REJECTED: Apache refuses the request before the .htaccess runs: 400 for a bad % escape or a path that climbs above the site’s root (/../), 404 for an encoded slash (%2F) or %00 in the path.
  • ERROR: the server answers with an error of its own: a page that isn’t in the site folder (404), a folder without an index file (403), or rules that rewrite in a loop (500).
  • REDIRECTED: the visitor is sent elsewhere; Goes to shows where, and Status the code (301, 302 and so on).
  • REWRITTEN: the URL stays, but Apache serves another path, such as WordPress’s /index.php; Goes to shows it.
  • NOT TESTED: a rule that decides depends on something a URL doesn’t hold, such as the visitor’s IP address.
  • UNCHANGED: Apache serves the URL as asked.

A redirect on the site (the same host, with or without www.) is followed as a browser follows it, up to 10 redirects: Hops counts them and Ends at says where the visitor lands (200 OK at https://..., an error, another site), or Loop: back to ... when the redirects go round in a circle.
A chain of two or more is worth shortening: each redirect costs the visitor a round trip, and search engines may not follow long chains.

For every error, Error page says what the visitor sees: the page, text or URL of the .htaccess’s ErrorDocument for that status, or Apache’s own page (always Apache’s own for REJECTED, which happens before the .htaccess is read). A local error page is requested again inside the server and goes through the .htaccess like any URL.
When a rule blocks it or it is missing, the visitor gets Apache’s own page with a note that the error page failed, and the steps show why.
Section names the part of the file the deciding rule is in, from its # BEGIN WordPress or # 8G:[REQUEST URI] comment, beside its line and the line of the condition that matched.

Select a row to see its steps below the table: each rule that applied, each round, each redirect followed, the error page, and what Apache served. Beside them, the .htaccess file shows the rule that decided, its conditions marked and the condition that matched in bold.
Rules that no URL in the run triggered are dimmed there and listed under Rules: candidates for cleanup, or a sign that your URL list misses a case. Drag the dividers to give either more room.

The URL goes through the file as Apache 2.4 with its default settings takes it:

  • %xx escapes in the path are decoded, // becomes /, and /./ and /../ are resolved before the rules test the path, while the query string is tested exactly as sent. So /wp-config.php%2Ebak is blocked as .bak, and ?q=eval%28 isn’t blocked by a rule looking for eval(.
  • RewriteRules run in the file’s order, each rule’s pattern first, then its conditions in order (a chain of [OR] conditions stops at the first that holds). [C], [S], [N], [L], [END], [QSA], [QSD] and [NE] work as in Apache, and a rewritten URL goes through the file again, as Apache’s internal redirect does, up to 10 times.
  • Redirect and RedirectMatch run after the RewriteRules in each round, on the path asked for, so a Redirect still applies beside WordPress’s rules (and gets the query string they leave, as on a real server).

The bar above the table counts each result. Click a heading to sort by it, and again to reverse. Right-click a heading to filter: Result, Status, Check, Expected, User agent, Agent type, Hops, Error page, Section, the line numbers, the pattern and the details list their values to check; URL, Goes to, Ends at, Path served and Query string take a text to search for. Clear filters shows every row again. Right-click a row to copy its URL or the whole row.

Testing user agents

Check “Test each URL with the user agents checked in the list” under Server, and each URL is simulated once for each user agent checked, a row each, with the user agent’s name and type in their own columns.
Click User agents… to see the list. Each entry shows:

  • Type: Browser, Search engine crawler, AI crawler, Social preview bot, SEO crawler, Monitoring, Tool or library, Security scanner, or Other.
  • Expected: Allowed (it should get what a browser gets for the same URL), Blocked (it should be DENIED), or Any (not checked).
  • List: Default for the entries that come with the app, Added by you for your own.

The defaults cover the common browsers on Windows, Mac, iPhone and Android, the main search engines (Googlebot, Bingbot, DuckDuckBot, Applebot, YandexBot, Baiduspider), the major AI crawlers (OpenAI’s, Anthropic’s, Perplexity’s, Amazon’s, Meta’s and Common Crawl’s), social preview bots and an uptime monitor, all expected to be allowed; tools (curl, Wget, Python, Go, Perl) and security scanners (sqlmap, Nikto, Nmap, masscan, WPScan, Nuclei, zgrab), expected to be blocked; and two SEO crawlers and an empty user agent, not checked.

Click in the Test column (or press Space) to check or uncheck an entry. Select one to see it below the table: a default’s expected result can be changed; fill in the fields and click Add as new for your own entry, which you can change (Save changes) or remove later. Restore defaults checks every default again with its first expectation. Check all and Check none do what they say. The list is saved as you change it, in user-agents.json in the working folder.

Each row’s Check then shows whether the user agent got what it should: a FAIL on a scanner means it slips through your rules, a FAIL on a browser or crawler means your rules block a visitor you want. The URL list’s own expected results aren’t used in this mode.

Checking expected results

Write what each URL should get after it in a TXT list, or in a column named expected in a CSV list, and every run checks it:

https://www.example.com/wp-config.php DENIED 403
http://www.example.com/about/ REDIRECTED 301 https://www.example.com/about/
https://www.example.com/ REWRITTEN /index.php
https://www.example.com/shop/ UNCHANGED

An expectation is any of a result (DENIED, REDIRECTED, NOT TESTED and so on), a status (301) and where the URL goes (a URL, or a path for a rewrite), in any order and case. A redirect passes when its first target or the end of its chain matches. Check shows PASS or FAIL, failed checks come first in bold, the steps end with what differed, and the counts say how many passed. Use a list like this as a test to run after every edit.

Writing a CSV file

Check “Write the results to a CSV file” and choose where it goes; each run then writes every result (not only the rows a filter shows), blocked first, with its steps on one line. The file opens in Excel as it is: UTF-8, a heading line, and a value that Excel would take for a formula kept as text.

The console

--show-window FALSE runs the simulation without the window. It prints each URL that needs a look (denied, rejected, in error, not tested, failing its check, or redirected in a chain, a loop or to an error; every URL with --print-results all), with what decided it, where it goes and the error page, then the rules no URL triggered and the counts:

$ python htaccess-rule-simulator.py --show-window FALSE --htaccess-file-path .htaccess --input-file-path urls.txt --site-folder-path site
DENIED      https://www.example.com/wp-config.php
            403 Forbidden from rule line 36 (8G:[REQUEST URI]), condition line 34: (/)(wp-config\.php|xmlrpc\.php|\.git|\.env)
            Error page: /errors/403.html (ErrorDocument line 4), with status 403.
REJECTED    https://www.example.com/files/report%2Fq3.pdf
            404 Not Found. Apache refuses the request before the .htaccess runs: an encoded slash (%2F) or NUL (%00) in the path.
            Error page: Apache's default page: Not Found. The requested URL was not found on this server.
...
REDIRECTED  http://example.com/garden-tips/
            301 Moved Permanently from rule line 16 (Force https and www), condition line 14: off
            Goes to https://www.example.com/garden-tips/
            Ends after 2 redirects: 200 OK at https://www.example.com/blog/
Not triggered by any URL: ErrorDocument line 5; RewriteRule line 42.
Simulated 27 URLs. DENIED: 10 | REJECTED: 2 | ERROR: 1 | REDIRECTED: 5 | REWRITTEN: 7 | NOT TESTED: 0 | UNCHANGED: 2 | Expected: 5 passed, 1 failed

With --test-user-agents TRUE, each line names the user agent too (DENIED https://... as curl (tool or library)).
With --test-url, the URL’s result is printed whatever it is. The exit status is 0 when the simulation ran (whatever it found), 1 when it couldn’t (a missing file, nothing to simulate in the .htaccess, no URLs), and 2 for a mistake on the command line.

Command line

Every option takes a value, as --name VALUE or --name=VALUE, in any order. Without --show-window FALSE, the window opens with every option given filled in, even several sources at once: the first one given is picked, and you sort out the rest there. It simulates at once when the .htaccess file and exactly one complete source are given. In the console, give one source; more than one is a mistake.

  • --working-folder-path FOLDER: where the settings file goes (blank: the script’s folder).
  • --htaccess-file-path FILE: the .htaccess file at the site’s root (blank: in the window, the one used last time).
  • --test-url URL: a single URL to simulate.
  • --input-file-path FILE: a TXT or CSV file of URLs, each with its expected result if you like.
  • --csv-column NAME: the column of URLs in a CSV input file, in any case (blank: url).
  • --sitemap-url URL: a sitemap or sitemap index.
  • --base-url URL and --local-folder-path FOLDER: a site’s address and a folder whose files become URLs.
  • --site-folder-path FOLDER: a copy of the site’s files, for file tests and missing pages (blank: none).
  • --user-agent TEXT: the browser’s user agent, as the rules see it (blank: Chrome on Windows).
  • --test-user-agents TRUE or FALSE: simulate each URL with each user agent checked in the list, kept in user-agents.json in the working folder (the default is FALSE: one user agent). It can’t go with --user-agent.
  • --print-results problems or all: in the console, print only the URLs that need a look (the default), or every URL.
  • --csv-file-path FILE: write every result to this CSV file (blank: no CSV file).
  • --show-window TRUE or FALSE: open the window (the default), or simulate in the console.

Keyboard shortcuts

Key Action
F5, Ctrl+R Simulate the URLs
Enter in a field Simulate the URLs
Ctrl+C in the table Copy the selected rows’ URLs
F1 About htaccess Rule Simulator: its version and links to its page

Limitations

  • Only the .htaccess file is read, as if it sat at the site’s root: rules in the server’s own configuration, other .htaccess files in subfolders, and RewriteMap aren’t known.
  • What is inside <Files>, <If> and similar sections is left out, with a warning under Rules; what is inside <IfModule> is read.
  • Rules that test the visitor’s address (REMOTE_ADDR) give NOT TESTED. Headers come from a browser: the user agent you choose, no referrer and no cookies.
  • Apache’s defaults are assumed (AllowEncodedSlashes Off, MergeSlashes On, Options without Indexes), with Debian’s and Ubuntu’s DirectoryIndex (index.html, index.php and the like) unless the .htaccess sets one.
    Patterns are run by Python’s regular expressions, which read ordinary patterns as Apache does; a pattern Python can’t read is listed under Rules as a warning, and its rule is skipped.
  • Redirects are followed only on the same site; a redirect to another site ends the chain there.

Version 1.4.0, updated 2026-11-28. infolific.com: https://infolific.com/technology/software-worth-using/ai-created/htaccess-rule-simulator/

⬇️ Download htaccess Rule Simulator.zip563.4 KBLast Updated: November 28, 2026Python

← All AI-created software