Document an htaccess to Nginx conversion as a versioned audit trail that links the original Apache rules to every generated line, warning decision, Nginx placement, validation result, and test outcome.
A conversion record is more than a before-and-after configuration diff. It should let another operator determine which exact input was in scope, which parts were translated, why each unsupported item was handled manually, where the result belongs, and what evidence supports reloading. This matters because Apache's directory-based .htaccess processing and Nginx's centralized server and location processing do not have interchangeable semantics. The Apache mod_rewrite introduction is a useful primary reference for understanding rule and condition evaluation on the Apache side.

What a Completed Record Must Contain
A useful migration document connects three fixed elements: the original Apache input, the generated output, and the application context in which that output will run. It should also preserve the human decisions made between conversion and deployment.
| Stage | What to record | Acceptance evidence |
|---|---|---|
| Scope | Source file path, document-root status, unchanged excerpt, and routes affected | Another operator can identify exactly what was submitted for review |
| Automatic conversion | The raw generated Nginx fragment and complete warning list | No warning is discarded or separated from its original line number |
| Manual review | Each warning, its disposition, supporting rationale, and any replacement configuration | No condition-dependent or unfamiliar rule is copied as a guessed equivalent |
| Assembly | Target file, server or location block, include path, and configuration diff | The final placement is visible in version control |
| Validation | Full nginx -t output, representative request results, reload result, and rollback procedure | Syntax and runtime behavior are supported by recorded evidence |
Store this material with the deployment record rather than in a private message or temporary notes file. A version-controlled configuration file, a migration log, and a test-result sheet create a clear chain from the source .htaccess excerpt to the deployed Nginx behavior.
Draw the Boundary Between Translation and Review
Use the htaccess to Nginx Converter as an inventory assistant for a focused first pass, not as a complete migration engine. Processing remains in the browser, and the submitted input is not sent to Lizely. The parser handles one bounded line at a time, ignores RewriteEngine On, preserves comments, and emits only the explicitly supported subset.
The supported rewrite form contains a pattern, a substitution, and a bracketed flag list. The automatic flag set is intentionally limited to L, R, R=301, and R=302. The following mappings can therefore be recorded as automatic translation results:
| Apache input | Generated Nginx construct | Point to document |
|---|---|---|
| RewriteRule with [L] | last | Confirm the rule operates in the intended root-context scope |
| RewriteRule with [R] | redirect | Record the expected destination and response status |
| RewriteRule with [R=301] | permanent | Test caching, query handling, hosts, and HTTPS before release |
| RewriteRule with [R=302] | redirect | Confirm that temporary behavior is intentional |
| Options -Indexes | autoindex off | Verify placement in the relevant server or location context |
| Local ErrorDocument 404 path | error_page 404 with the same path | Confirm that the target is local and remains available |
| Quoted X-Robots-Tag Header set value | add_header with the same header and value | Verify the header in the response rather than only in the source |
The converter inserts a leading slash for its restricted root-context rewrite pattern because an Nginx rewrite pattern sees a URI beginning with a slash. Document this assumption explicitly. It is not a universal transformation for nested .htaccess files, Alias mappings, or location-specific Nginx blocks.
Anything conditional, unfamiliar, or syntactically ambiguous is reported with its original line number for manual work. RewriteCond lines are never translated automatically, and a RewriteRule associated with a condition is also suppressed rather than emitted as an unconditional redirect. This is essential because Apache conditions can inspect HTTPS state, hostnames, files, directories, query strings, headers, and captured groups in an order that affects the result.
Unknown flags such as QSA, END, F, G, B, and NC produce a warning and no guessed output for that rule. The single-dash, no-substitution RewriteRule target is also withheld instead of being treated as a literal Nginx replacement. Other status codes, external error documents, conditional headers, environment variables, and directive containers require manual migration.
The output is a fragment, not a complete nginx.conf. It does not create an http, server, or location block and does not define a listen port, server_name, TLS, a document root, PHP routing, proxy behavior, or logging. The tool also does not run nginx -t, inspect installed modules, discover include order, or access the server, so those checks belong in the operator's documentation and release workflow.
Build a Reproducible Conversion Log
- Preserve the original input and scope. Save the exact .htaccess excerpt in its original form, along with the source path, whether it applies at the document root, the affected application routes, and the configuration revision being migrated. Do not silently correct Apache syntax inside the archived excerpt.
- Submit one focused excerpt. Paste a small document-root section into the converter. Keeping the input focused makes it easier to connect each result and warning to a specific source line, especially when the file contains several unrelated behaviors.
- Save the raw generated fragment and warnings. Retain the converter output before editing it for deployment. Preserve every line-numbered warning and identify the source line it references so that no unsupported item disappears between conversion and review.
- Review each emitted line and warning manually. Compare the generated construct with the Apache source and the official Apache and Nginx documentation. Record what changed in meaning, which context the directive requires, and whether the conversion is safe for the actual application architecture.
- Document each manual decision. For every warning, record the condition, flag, target, or ambiguous syntax involved; the reason it was not translated; and the chosen disposition. A disposition can be a hand-written Nginx equivalent, a request for engineering review, or a documented decision not to migrate that behavior.
- Assemble the reviewed lines in context. Place each directive in the correct server or location block inside a version-controlled Nginx file. Record the file path, parent server block, include path, and relevant application assumptions. Never paste the fragment into nginx.conf without this assembly step.
- Back up and validate the full configuration. Back up the active configuration, keep an open recovery session, and run nginx -t against the complete assembled configuration. Save the command output with the configuration revision; a successful conversion result is not itself evidence that the final file is valid.
- Test representative requests before reload. Use staging or a reversible environment where practical. Capture the requested URL, response status, Location header, relevant headers, and expected versus actual behavior for old paths, new paths, query strings, alternate hosts, and HTTPS.
- Reload only after the checks pass. Record the reload time, result, operator, and any exceptions. Keep the tested configuration revision and rollback procedure with the migration record so that an incident can be traced back to the exact rules that were deployed.
Capture Context That Changes Rule Meaning
The most important documentation often sits beside the source rule rather than inside the generated fragment. Record the following context before approving a migration:
- Directory scope: State whether the Apache rule came from the document root, a nested directory, an Alias, or a location-specific setup. The converter's leading-slash assumption applies to its restricted root-context pattern, not to every possible deployment.
- Condition dependencies: Note any HTTPS, hostname, file, directory, query-string, header, or captured-group condition. Apache's evaluation order and server architecture can change the meaning of the following rule, so a condition-dependent rewrite needs a manual Nginx design.
- Flag and target behavior: Identify flags that were not translated and explain why they cannot be removed safely. A no-substitution dash may combine with flags that alter access or processing without changing the URI.
- Application dependencies: Note authentication, authorization, hotlink protection, proxy logic, CMS front-controller behavior, and PHP routing. These cases require engineering work rather than bulk text replacement.
- URI-matching differences: Record whether the pattern assumes a directory-relative Apache path or a full Nginx URI. Matching strings, escaping, query handling, and loop behavior can differ even when the regular expressions look identical.
Verify Behavior, Not Just Syntax
nginx -t can validate assembled syntax and directive context, but it does not prove that the migrated routes serve the right content. Because the converter cannot access the server, your record must include operator-run request evidence.
- For a redirect, confirm the status code and inspect the Location header instead of relying on the browser address bar. Check old and new paths, query-string treatment, alternate hosts, and HTTPS behavior.
- For an internal last rewrite, verify the final resource and confirm that the request was not exposed as an unintended external redirect.
- For a local 404 rule, confirm both the status and the returned local error document. External error-document behavior belongs in the manual review.
- For directory controls, request a directory path and verify that indexing behaves as intended in the selected context.
- For an X-Robots-Tag rule, inspect the response header on representative pages and any redirects that should carry it.
- For rewrites involving captures or backreferences, test the exact captured values and destinations rather than assuming their behavior is identical.
Record each test as expected behavior, observed status, observed headers, observed destination or body, timestamp, and the tested configuration revision. Permanent redirects deserve extra care because browsers and intermediaries may cache them. When practical, test temporary behavior in a controlled environment before changing a redirect to permanent.
Finalize the Audit Trail
A completed conversion record should contain:
- The unchanged source excerpt and its scope notes
- The raw converter fragment and complete warning list
- A line-by-line manual decision record
- The final version-controlled Nginx configuration diff
- The full nginx -t output
- Representative request results and reload evidence
- The rollback path and any unresolved exceptions
This package lets a reviewer trace each source rule to an automatic conversion, an explicit manual decision, or a documented exclusion. That traceability is the central answer to how to document an htaccess to Nginx conversion: preserve the input, preserve the output, and record every decision that connects them to the deployed application.
If you're weighing options, Nginx Config Generator: From Inputs to Live Tests covers this in detail.
If you're weighing options, Comparing Ways to Generate .htaccess HTTPS Redirects covers this in detail.