.htaccess Redirect Generator - Apache & Nginx Rules
Generate 301 and 302 redirect rules for Apache .htaccess and Nginx from a list of old and new URLs. Includes ready-made templates for HTTPS, www removal, and trailing slashes.
Redirect Rule Generator for Apache and Nginx
Build correct redirect rules without memorizing Apache mod_rewrite or Nginx syntax. Paste a list of old paths and their new destinations, pick 301 or 302, and get two ready-to-use blocks: one for an Apache .htaccess file and one for an Nginx server configuration. Common site-wide patterns like forcing HTTPS, removing the www prefix, and adding trailing slashes are available as one-click templates.
Developers and site owners need redirects whenever they migrate a site, restructure URLs, rename blog posts, move from HTTP to HTTPS, or consolidate www and non-www versions of a domain. SEO specialists rely on 301 redirects to pass link equity from old URLs to new ones, and agencies use bulk lists like this during content migrations with dozens or hundreds of moved pages.
A 301 tells browsers and search engines the move is permanent, so Google transfers rankings to the new URL and browsers cache the redirect. A 302 marks a temporary move and keeps the original URL in the index, which is the right choice for A/B tests or maintenance pages. The generated Apache rules use the Redirect directive for simple path mappings and RewriteRule with conditions for the site-wide templates; the Nginx output uses return and rewrite statements, which Nginx evaluates faster than regex location blocks.
Redirect chains cost real performance: each hop adds a full network round trip, often 100-300 ms on mobile connections, and Google typically follows at most 10 hops before giving up. Point old URLs directly at their final destination instead of chaining through intermediate redirects, and test with curl -I to confirm the status code and Location header before going live.
After setting up redirects, check what each status code means with our HTTP Status Codes reference and keep your sitemap current. If you are reorganizing a site, the Slug Generator helps you create clean, SEO-friendly paths for the new URL structure.
How the Redirect Generator Works
- 01Paste redirects as 'old-path new-url' lines, or switch to single mode for one redirect.
- 02Pick 301 (permanent) or 302 (temporary) and enable any templates: force HTTPS, www to non-www, trailing slash.
- 03The tool builds matching Apache .htaccess and Nginx configuration blocks side by side.
- 04Copy the block for your server, paste it into .htaccess or your Nginx config, and reload.
Setting Up Redirects the Right Way
List every moved URL as a pair per line: the old path (starting with a slash) followed by the full destination URL. The generator normalizes paths that are missing the leading slash and skips malformed lines with a clear warning, so you can paste straight from a migration spreadsheet. Choose 301 for permanent moves so search engines transfer rankings, or 302 when the change is temporary. The site-wide templates cover the three most requested patterns: forcing HTTPS with a rewrite condition on the HTTPS flag, folding www traffic onto the bare domain, and appending trailing slashes to directory-style URLs while leaving real files alone. For Apache, place the output in the .htaccess file at your document root (mod_rewrite and mod_alias must be enabled, which they are on nearly all shared hosting). For Nginx, the path redirects belong inside your existing server block, while the HTTPS and www templates are standalone server blocks; replace example.com with your domain. Reload the server and spot-check a few URLs with curl -I to confirm the status code and Location header.
When to Use the Redirect Generator
Reach for it during site migrations, domain changes, URL restructures, and HTTPS rollouts - any moment old URLs must land visitors and search engines on new ones. It is equally useful for one-off fixes, like a renamed blog post that still gets traffic from social links, and for standardizing a site on one canonical host and protocol. If you manage both Apache and Nginx environments, the side-by-side output saves you from translating syntax by hand.
Common Use Cases
- Migrating a website to a new URL structure with a bulk list of moved pages
- Forcing all traffic to HTTPS after installing a TLS certificate
- Consolidating www and non-www hostnames onto one canonical domain
- Redirecting renamed blog posts so old backlinks keep working URL Slug Generator - SEO-Friendly Slugs
- Looking up what a 301 or 302 response actually means HTTP Status Codes - Complete Reference
Expert Tips
- Test with curl -I before announcing a migration: it shows the exact status code and Location header without browser caching getting in the way.
- Browsers cache 301s aggressively; while testing, use 302 first and switch to 301 once the mapping is final.
- Keep your redirect list in version control next to your site code, so the mapping survives server moves.
Frequently Asked Questions
- Use 301 when the move is permanent: search engines transfer ranking signals and browsers cache the redirect. Use 302 for temporary situations such as A/B tests or maintenance pages, where you want the original URL to stay canonical.
- In the .htaccess file in your site's document root, or directly in the virtual host configuration if you have server access (which is faster because .htaccess is evaluated on every request).
- Nginx handles protocol and hostname redirects most efficiently with dedicated server blocks that return 301 immediately, rather than rewrite rules inside your main block. The path redirects, by contrast, drop into your existing server block as location lines.
- Yes. Each hop adds latency and Google follows a limited number of hops. Always point old URLs directly at the final destination, and update the list when a destination moves again.
Should I use 301 or 302?→
Where do I put the Apache rules?→
Why are the Nginx templates full server blocks?→
Do redirect chains hurt SEO?→
Related tools
12 suggested- 01DNS Lookup - A, MX, TXT, NS & MoreQuery A, AAAA, MX, TXT, NS, CNAME, SOA, and CAA records for any domain via DNS-over-HTTPS. Free browser-based DNS lookup with a query-all mode.
- 02ZIP Extractor - Open ZIP Files OnlineOpen and extract ZIP files directly in your browser: list contents, preview text and images, download files. Free and private - nothing is uploaded.
- 03User Agent Parser - Browser & OS LookupParse any user agent string to identify browser, version, engine, OS, and device type, including bots. Free, instant, and fully browser-based.
- 04HTML to JSX Converter - Free & InstantConvert HTML to valid React JSX instantly: className, camelCase attributes, style objects, and self-closed tags. Free, browser-based, and private.
- 05Generate .env.example Files - Free & PrivatePaste a .env file and instantly get a .env.example with secret values stripped. Free, browser-based, and private - credentials never leave your device.
- 06JSON Formatter & Validator - Instant ResultsFormat, validate, and minify JSON with instant error highlighting. Pinpoints syntax errors. Free, private, browser-based.
- 07JSON to CSV Converter - Export InstantlyConvert JSON arrays to CSV format with automatic header detection. Download as CSV file. Free, browser-based - no upload needed.
- 08CSV to JSON Converter - Auto-Detect FormatConvert CSV data to JSON format instantly. Auto-detects delimiters and headers. Free, private, browser-based - no upload needed.
- 09JSON to XML Converter - Instant & FreeConvert JSON data to XML format with proper indentation and escaping. Free, browser-based converter - no upload needed.
- 10JSON Tree Viewer - Expandable VisualizerVisualize JSON data as an expandable, collapsible tree. Search keys and values, copy JSON paths. Free online JSON explorer.
- 11JSON Schema Validator - Free Online ToolValidate JSON data against a JSON Schema instantly. Perfect for AI function calling and API validation. Free, browser-based.
- 12Regex Tester - Live Matching & HighlightingTest regular expressions with live matching and highlighting. Supports all flags and capture groups. Free online regex debugger.