.htaccess Redirect Generator
Generate Apache .htaccess redirect rules from URL pairs
Enter URL pairs above to generate redirect rules.
Try these next
Why use .htaccess Redirect Generator
- Bulk import generates hundreds of redirect rules from a spreadsheet in seconds -- no manual .htaccess editing.
- Correctly escapes special characters in URL paths, which is the most common source of silent breakage in hand-written rules.
- Supports both Redirect (simple, fast) and RewriteRule (regex, conditional) syntax depending on what your setup needs.
- 410 Gone support lets you cleanly signal intentional page removal to search engines instead of leaving broken 404s.
- Real-time output preview means you can catch formatting errors before they go live.
- No Apache documentation lookup required -- pick status code, enter URLs, copy.
How it works
The generator takes pairs of old and new URLs and formats them as Apache .htaccess directives. In Redirect mode, it outputs simple Redirect directives with the status code, old path, and new URL on a single line. In RewriteRule mode, it wraps each pair in a RewriteRule with the old path converted to a regex pattern (special characters escaped), the new URL as the substitution, and flags like [R=301,L] that set the redirect status and stop further rule processing. The 410 Gone type always uses a RewriteRule with the [G,L] flag since the Redirect directive does not support the 410 status directly. The bulk import parser splits input by newlines, then separates each line by commas or tabs to extract old and new URL columns. All URL paths are trimmed, and RewriteRule patterns strip the leading slash because Apache matches against the path portion without it in per-directory .htaccess context.
About this tool
You're migrating 200 pages to a new URL structure and every missing redirect means lost traffic, broken bookmarks, and wasted link equity. Enter old/new URL pairs one at a time or use bulk import to paste them from a spreadsheet. The tool generates properly formatted Apache .htaccess directives -- either simple Redirect or RewriteRule with mod_rewrite -- in the status code you need: 301 (permanent, transfers ranking signals), 302 (temporary), 307 (temporary strict), or 410 (gone, no replacement). Special characters in URL paths are escaped correctly, which is the thing most people get wrong when hand-writing .htaccess rules. Output updates in real time and copies with one click. If you're on WordPress or cPanel, paste the rules directly into your .htaccess through the file manager.
How to use .htaccess Redirect Generator
- Enter your old URL. Type or paste the old URL path that should be redirected. Include the leading slash for relative paths or the full URL.
- Enter your new URL. Type or paste the destination URL where visitors should be sent. Use a full URL for external redirects or a relative path for internal ones.
- Select the redirect type. Choose 301 (permanent), 302 (temporary), 303 (see other), 307 (temporary strict), or 410 (gone) depending on your use case.
- Add more rules or use bulk import. Click 'Add Rule' to add more redirect pairs one at a time, or switch to Bulk Import to paste multiple old/new URL pairs from a spreadsheet.
- Copy and paste into .htaccess. Click Copy to grab the generated rules and paste them into your .htaccess file on your Apache web server.
Use cases
- Migrating from one CMS to another. Export the URL map from a spreadsheet, bulk-import, generate all 200 redirect rules in under a minute.
- A crawl report shows 50 broken backlinks pointing to old URLs. Generate a redirect map to preserve domain authority.
- Two microsites are consolidating onto one domain. Bulk-import the legacy landing page URLs, set all to 301, paste into .htaccess.
- Discontinued product pages need to disappear from search indexes cleanly. Generate 410 Gone rules instead of leaving 404s.
- A redesign is in progress. Set up temporary 302 redirects so the client can preview the new site without losing SEO on the live URLs.
- An agency audit found that a client's .htaccess has broken regex patterns. Regenerate the rules with properly escaped characters.
Frequently Asked Questions
A .htaccess file is a configuration file used by Apache web servers to control directory-level settings. It sits in your website's root directory (or any subdirectory) and can handle URL redirects, access control, custom error pages, MIME types, and caching rules. Changes take effect immediately without restarting the server. The filename starts with a dot, which makes it a hidden file on Unix-based systems.
A 301 redirect is permanent and tells search engines to transfer all ranking signals and link equity to the new URL. Use 301 when a page has moved permanently. A 302 redirect is temporary and tells search engines to keep the original URL in their index. Use 302 when the redirect is temporary, such as during maintenance or A/B testing. Using the wrong type can hurt your SEO rankings.
Use RewriteRule (mod_rewrite) when you need pattern matching, regular expressions, or conditional logic in your redirects. Simple one-to-one URL redirects work fine with the Redirect directive, which is easier to read and slightly faster for Apache to process. RewriteRule is necessary for complex scenarios like redirecting based on query strings, user agents, or when you need to rewrite URLs without a visible redirect.
A 410 Gone status tells search engines and browsers that a page has been intentionally and permanently removed with no replacement URL. Unlike a 404 (which suggests the page might return), a 410 explicitly signals permanent removal. Search engines will de-index the URL faster when they encounter a 410. Use this when you want to cleanly remove pages from search results rather than redirecting them.
Connect to your web server via FTP, SFTP, or your hosting control panel's file manager. Navigate to your website's root directory (usually public_html or www). If a .htaccess file exists, download it and add the generated rules. If it does not exist, create a new file named .htaccess (with the leading dot). Paste the redirect rules, save, and upload. Test your redirects immediately by visiting the old URLs in your browser.
Yes. Switch to Bulk Import mode and paste your old and new URL pairs separated by commas or tabs, one pair per line. You can export your URL mapping from a spreadsheet and paste it directly into the bulk input field. The tool generates all the redirect rules at once, saving significant time compared to writing each rule manually. Select the redirect type (usually 301 for migrations) before importing.
No. The .htaccess file and the Redirect and RewriteRule directives are specific to Apache web servers. Nginx uses a different configuration syntax in its server block files, and Microsoft IIS uses web.config with XML-based rewrite rules. If you are using Nginx or IIS, you will need to convert the generated rules to the appropriate format for your server.
A 307 Temporary Redirect is similar to a 302 but strictly preserves the HTTP method of the original request. When a browser receives a 307, it must use the same method (GET, POST, PUT, etc.) for the redirected request. A 302 technically allows browsers to change the method, though most modern browsers preserve it anyway. Use 307 when you need guaranteed method preservation, particularly for form submissions and API endpoints.
Related Tools
Discover more free utilities to enhance your productivity.
Meta Tag Generator
Generate title, description, Open Graph, and Twitter Card tags from one form
Regex Tester
Type a regex pattern and see matches highlighted instantly in your test string
URL Encoder / Decoder
Percent-encode text for URLs or decode %20-style strings back to readable text
Cron Expression Generator
Build cron expressions visually or decode existing ones to plain English