htaccess Redirect Generator
A redirect rule that compiles and sends visitors to the wrong place is the failure people actually ship, because nothing complains — the server does exactly what the rule says. So every rule generated here is applied to an example path and the result is written above it as a comment, and the page checks that the rule really does send that path where the comment claims. The status codes are on every line too: a 301 is cached by browsers for a very long time and is hard to take back.
What this generator does
Writes a RewriteEngine block of one to six rules, each with a capture group carried into its target, an example path in a comment above it, and an explicit redirect status. Every rule is then applied to its example path and the result compared with the comment.
How to use this tool
- Choose how many redirects you want.
- Generate, and read the example path above each rule.
- Check the verification note.
- Adapt the patterns to your own paths, keeping the example comments up to date.
Understanding the controls
- How many redirects
- One to six. Each is a different pattern, so the block shows several shapes of rule rather than one repeated.
Common use cases
- Starting a redirect block after a site restructure
- Showing the difference between a permanent and a temporary redirect
- Producing fixtures for something that parses rewrite rules
- Teaching how a capture group is carried into the target
- Checking your own rules against a working example of the same shape
How this generator works
Each rule keeps the captured text as the shared quantity: the example path and the target are both built from it, so neither is derived from the other by string surgery. The check compiles the pattern, matches it against the example, substitutes the capture into the target the way the server would, and compares. An earlier version built the example by editing the pattern text and produced a target ending “.zip.zip” — the check caught it, because it applies the rule rather than repeating the arithmetic that made it.
Randomness and fairness
Which patterns appear, the captured slugs and the choice between 301 and 302 are drawn with your browser's cryptographic random source.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Apache RewriteRule syntax only — nginx, Caddy and IIS all express redirects differently.
- No conditions: RewriteCond, host matching, query strings and HTTPS enforcement are all out of scope here.
- The patterns are examples of common shapes rather than rules for your site, and the paths in them are invented.
- The check confirms each rule lands where it claims, not that the destination exists on your server.
- A 301 is cached hard by browsers. Test with a 302 first — the page offers both for that reason.
Privacy and your data
Rules are generated in your browser from built-in patterns. You enter nothing, nothing is uploaded or stored, and analytics records only that the tool ran and how many rules were made.
Related generators
- cURL Command GeneratorA sample curl request with headers and a JSON body, quoted properly and checked by reading it back as a shell would.
- Docker Compose File GeneratorA sample docker-compose.yml with an app service, a data store, a volume and a network — parsed back and checked before you see it.
- Kubernetes Manifest GeneratorA sample Deployment, Service or ConfigMap with the required keys present, the names legal and the labels actually matching.
- Mock API Response GeneratorA sample successful JSON API response, distinct from the site's error-shaped mock response tool.