Htaccess Redirect Generator
Generate carefully validated Apache redirects.
What Is an Htaccess Redirect Generator?
An htaccess redirect generator helps you prepare Apache redirect instructions that send visitors from an old URL to a new destination. It is useful when you rename a page, change a permalink, or move a website. Depending on the available options, generated rules may use Apache Redirect directives or RewriteRule syntax. You must review the code, add it to the correct server configuration, and test the result; generating a rule does not activate it on your website.
Htaccess Redirect Generator
Generate carefully validated Apache redirects.
Create Apache .htaccess redirect rules
Handles literal root-relative source paths only, not regex input or arbitrary expressions. Flags duplicate sources, redirect chains and loops for review. Output is for Apache with mod_rewrite; test in staging before inserting it above the WordPress rewrite block. Nothing on your server is changed automatically.
Create Apache Redirects Without Breaking Existing URLs
Changing a web address is easy; keeping the old address useful requires more care. A link in an old article, an email, or a search result may continue pointing to the previous path after the page moves. A server-side redirect tells the browser where to request the replacement. Apache sites can configure many redirects through a file named .htaccess, provided the server permits the relevant directives.
Use the generator to prepare a redirect, then inspect the source, destination, and HTTP status before applying anything. A one-page move, a complete folder move, and an HTTPS or hostname change are different operations. The examples below show how Apache treats them, why seemingly correct rules sometimes affect extra pages, and how to deploy changes without disrupting WordPress or creating redirect loops.
Read Full GuideShow Less
Start With the Old URL and Its Real Replacement
Before writing a rule, identify the address people already use and the page that should replace it. For example, if https://example.com/services/old-audit/ has moved to https://example.com/services/seo-audit/, the first address is the source and the second is the destination. Both should be intentional: the target must exist, load correctly, and answer substantially the same need.
Do not send every deleted post to the homepage merely to eliminate 404 errors. A generic homepage usually does not replace a discontinued service or a missing tutorial. If no relevant successor exists, removing obsolete internal links and returning an appropriate 404 or 410 can be better than a misleading redirect. For large moves, prepare the URL relationships with a Website Migration URL Mapper before generating server rules.
Choose 301 or 302 Based on Whether the Move Will Last
A 301 Moved Permanently response tells browsers and search engines that a page has moved indefinitely. It is the usual choice for renamed posts, consolidated content, and permanent site migrations. A 302 Found response describes a temporary change, such as a short maintenance detour that you intend to undo. Other status codes exist: 307 is temporary and 308 is permanent, with stronger guarantees about preserving the original request method.
| Status | Typical use | What to remember |
|---|---|---|
| 301 | Permanent page or domain move | A strong signal that the replacement is the preferred URL |
| 302 | Temporary move or short-lived detour | Do not use as the default for an irreversible migration |
| 307 | Temporary redirect that preserves the request method | Useful when request-method behavior matters |
| 308 | Permanent redirect that preserves the request method | Consider application and client compatibility |
Neither a status code nor a generator guarantees search rankings. Search engines evaluate the destination, other canonical signals, and whether the move is coherent. Avoid changing the response code merely because an SEO checker labels a different one as better.
Know When a Simple Redirect Matches More Than One Page
For a straightforward move, Apache’s mod_alias module supports a compact directive. This example asks Apache to issue a permanent redirect:
Redirect 301 /catalog /shop
The significant detail is that Redirect uses a path-prefix match on path-segment boundaries. A request for /catalog/item-a can therefore be redirected to /shop/item-a. That is convenient for a moved folder, but it may be unintended if only one page should change. It does not ordinarily match a separate segment such as /catalogue.
For a single exact path, a carefully anchored rewrite rule gives you narrower control. Always check the actual style the generator supplies instead of assuming that a line which looks like a one-page redirect cannot also affect descendants.
Make an Exact Page Redirect With RewriteRule
In a document-root .htaccess file, the following example matches /guides/old-pricing and /guides/old-pricing/, and redirects either form to the new pricing page:
RewriteEngine On
RewriteRule ^guides/old-pricing/?$ /pricing/ [R=301,L]
The caret and dollar sign anchor the path at its beginning and end. The /? accepts an optional trailing slash. R=301 requests a permanent external redirect, and L ends the current rewrite-rule pass. Apache removes the directory prefix before applying rewrite patterns in .htaccess, so the pattern above deliberately does not begin with a slash.
This is a worked Apache example, not a claim that the generator produces exactly these lines. If your site runs in a subdirectory, uses unusual rewrites, or has existing rewrite conditions, the required pattern and ordering may differ. Review the complete configuration rather than pasting snippets blindly.
Place Custom Redirects Around WordPress Rules Carefully
On many Apache WordPress installations, the root .htaccess contains a section marked # BEGIN WordPress and # END WordPress. WordPress or another component may regenerate the contents of that managed block. Keep independently maintained custom rules outside the autogenerated section, and position applicable rewrite redirects before the WordPress catch-all rewrite so they are evaluated first.
Back up the existing file before changing it. Use your hosting file manager, secure file transfer, or another approved server-management method. The file name begins with a dot, so it may be hidden in hosting interfaces. A syntax error or a rule that redirects requests back to themselves can make many pages inaccessible, sometimes producing a 500 response or a browser’s too-many-redirects warning.
Apache must permit the directives used by your rule; AllowOverride settings and the availability of mod_rewrite matter. Nginx does not read .htaccess files. A WordPress site served by Nginx needs an equivalent rule in its supported server or platform configuration instead.
Check HTTPS, WWW, and Query Strings Separately
URL moves are not limited to changing the part after the hostname. Redirecting from HTTP to HTTPS, changing www.example.com to example.com, or combining both transformations requires attention to the server’s actual request environment. Enabling opposite hostname rules can cause loops, while separate HTTPS and hostname redirects can produce avoidable extra hops.
Reverse proxies and CDNs complicate the picture because the connection between a proxy and your server may use a different scheme from the browser-facing connection. A simple HTTPS condition that works on one host can loop behind another. Follow the hosting provider’s approved configuration before adding a sitewide HTTPS rule.
Also test URLs that include query strings, such as /old-page/?ref=newsletter. Depending on the directive and substitution, Apache may carry existing parameters forward. Some migrations need that behavior; others must intentionally remove or transform parameters. A URL Parameter Cleaner can help you inspect URL forms, but it does not replace the need to test how your server handles the redirect.
Test the Response, Final Destination, and Redirect Chain
- Save a recoverable copy of the original
.htaccessbefore editing. - Confirm that the new target already returns a successful response and displays the expected content.
- Apply one narrowly scoped rule first, ideally in a staging environment.
- Request the old URL and verify its response status and
Locationheader. - Follow the redirect and confirm the final destination responds correctly without returning to the original URL.
- Check trailing-slash variants, query parameters, and nearby paths that should remain unchanged.
- Roll back immediately if unrelated pages break; then revise and retest the rule.
A Bulk HTTP Status and Redirect Checker can assist with checking multiple old addresses after a migration, while the Redirect Rule Tester is relevant when reviewing rewrite behavior. Neither should be assumed to have deployed rules on the server; a generated configuration is only an instruction until your server reads it.
Avoid Redirect Chains and Conflicting URL Maps
A redirect chain occurs when an old URL sends a visitor to an intermediate URL that redirects again. For example, /old-service/ might move to /services/, which then moves to /services/audit/. If /services/audit/ is the correct destination, revise the first mapping to reach it directly. This reduces needless requests and makes the configuration easier to maintain.
Check for duplicate source paths, competing permanent and temporary rules, broad folder matches above more specific exceptions, and rules maintained both in the web server and a WordPress redirect plugin. The same URL may also be redirected by your CDN. When different layers issue conflicting responses, edit the layer responsible rather than adding another redirect to conceal the problem.
For CSV-based site migrations, verify that source and destination columns are consistently formatted before importing rules elsewhere. The WordPress Redirect CSV Validator can support that preparation. Large rule collections should be reviewed for collisions and tested in batches, not treated as correct merely because their syntax was generated automatically.
When Is a Redirect Generator Not Enough?
Creating syntax and validating a live redirect are two separate jobs. A generator cannot know which redirects already exist at your CDN, which paths your application uses, whether the replacement page is relevant, or whether your hosting configuration will accept the result. It also cannot make an Nginx server interpret Apache directives. These are deployment and verification responsibilities.
Use an htaccess redirect generator when you need a clear starting rule for an Apache-compatible setup, then verify the rule against your actual environment. For a permanent URL move, update internal links and XML sitemap entries to the final addresses as well. Redirects protect visitors who still use old URLs; clean internal navigation helps your site point to the right destinations from the outset.