Redirect Rule Generator
Generate 301/302 redirect rules for Apache (.htaccess) and Nginx from fixed templates, with validated paths — never arbitrary, unvalidated server config.
Each rule becomes a Redirect 301 /old /new line for Apache's mod_alias and a location = block returning the same status code for Nginx. This deliberately does not generate regex rewrite rules or arbitrary server directives — only fixed templates filled with your validated source and destination. A 301 tells crawlers and browsers the move is permanent (search engines transfer ranking signals to the new URL); a 302 signals a temporary move and should not be used for a permanent restructure.
Query strings behave differently between the two outputs for the same rule: Apache's Redirect directive automatically forwards the original request's query string to the destination, but the Nginx template above does not — a request to /old?ref=email keeps ?ref=email on Apache, but arrives at the destination with no query string at all on Nginx. Don't assume the two are equivalent if your links carry query parameters.
Subpaths also differ: the Nginx block matches only the exact path, but Apache's Redirect matches the path and everything beneath it and appends the rest — with Redirect 301 /old /new, a request for /old/page goes to /new/page. If other URLs start with your source path, check them before deploying the Apache rule.
Generated entirely in your browser — nothing you enter here is sent to a server, and no live site is checked or modified.
Generates ready-to-use redirect rules for the two most common web servers — Apache (.htaccess) and Nginx — from a source path, destination, and redirect type. Every rule is built from a fixed, verified template; nothing you type is inserted into the server config as raw, unvalidated text.
Use a 301 (permanent) redirect when a page has moved for good — search engines transfer most of the old URL's ranking signal to the new one. Use a 302 (temporary) redirect only for a short-term move, since search engines keep indexing the original URL.
How to use the Redirect Rule Generator
- In Rule 1, enter the old path in From (source path), starting with a slash.
- Enter the new location in To (destination), either a path like /new-page or a full https:// URL, and choose 301 (permanent) or 302 (temporary) under Type.
- Click Add another rule for each extra redirect; use Remove to drop one.
- Click Generate, then use Copy above the Apache (.htaccess) or Nginx output and paste it into your server config.
Example: One permanent and one temporary redirect
Rule 1: From /old-pricing, To /pricing/, Type 301. Rule 2: From /summer-sale, To https://shop.example.com/sale, Type 302. Click Generate. Apache shows "Redirect 301 /old-pricing /pricing/" and "Redirect 302 /summer-sale https://shop.example.com/sale"; Nginx shows two blocks such as "location = /old-pricing { return 301 /pricing/; }", each on separate lines.
Questions about the Redirect Rule Generator
- Can I paste a full URL into the From field?
- No. The source must be a site-relative path starting with "/", because the rule runs on the server that receives the request. Only the destination may be a full http:// or https:// URL.
- Why are some of my rules rejected?
- Each rule needs both fields; paths and URLs cannot contain spaces, quotes, braces or semicolons; a source path cannot contain ? or #; the source and destination cannot be identical; and two rules cannot share the same source path. Errors are listed with the rule number they apply to.
- Can I redirect a URL with a specific query string, like /page?id=5?
- No. Apache's Redirect and Nginx's location match only the path, never the query string, so the tool rejects a source containing ? or #. Query-based redirects need rewrite rules, which this tool does not generate.
- Do the Apache and Nginx rules match exactly the same requests?
- Not quite. The Nginx location = block matches only the exact path, while Apache's Redirect also matches paths beneath it, so a request for /old-pricing/plans is also redirected, with /plans appended to the destination. Test both on a staging server first.