htaccess Redirect Generator
Build Apache .htaccess 301 and 302 redirect rules.
Redirect type
From (old path)To (new path or URL)
.htaccess
# Redirect rules — place in your site's .htaccess (mod_alias) Redirect 301 /old-page /new-page Redirect 301 /blog/old-post https://example.com/blog/new-post
How .htaccess redirects work
On Apache servers, a .htaccess file can redirect old URLs to new ones using the Redirect directive (mod_alias). A 301 is a permanent move and passes SEO ranking to the new URL; a 302 is temporary. The from is a path on your site (starting with /); the to can be a path or a full URL. Rules are generated in your browser — paste them at the top of your .htaccess.
Related: the canonical tag generator, the robots.txt generator, and the htpasswd generator.
Frequently Asked Questions
What is an .htaccess file?
An .htaccess file is a per-directory configuration file for Apache web servers. It lets you set URL redirects, rewrite rules, password protection, and cache headers without editing the main server configuration.
What's the difference between a 301 and 302 redirect?
301 (Permanent) tells search engines the page has moved forever — the old URL's SEO equity transfers to the new one. 302 (Temporary) tells search engines to keep indexing the old URL. Use 301 for site migrations and URL restructures.
Does .htaccess work on Nginx or other web servers?
No. .htaccess is Apache-only. Nginx uses its own server block configuration (nginx.conf). For Cloudflare Pages, use a _redirects file instead. Translate your RewriteRules to server-specific equivalents when switching.
How do I force HTTPS with .htaccess?
RewriteEngine On, then: RewriteCond %{HTTPS} off, followed by RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]. This catches all HTTP requests and permanently redirects to the same HTTPS URL.
Can I use wildcards in .htaccess redirects?
Yes. RewriteRule uses regular expressions on the request URI. '(.*)' captures everything; '^old-path/(.*)$' captures a sub-path. Reference captured groups in the replacement with $1, $2, etc.
Private & free — this tool runs entirely in your browser.
Recommended: Bluehost — Reliable WordPress & web hosting — exclusive pricing from $3.79/mo.affiliate
Related Web & SEO tools
Meta Tag Generator
Build SEO title, description, and viewport meta tags.
Open Graph Generator
Generate Open Graph and Twitter Card meta tags.
Robots.txt Generator
Build a robots.txt file with per-bot rules. Block AI crawlers, set crawl delays, define sitemaps.
UTM Campaign URL Builder
Append UTM parameters to build trackable campaign URLs.
Hreflang Tag Generator
Generate hreflang link tags for multilingual SEO.
Sitemap XML Generator
Build an XML sitemap from a list of URLs.
SERP Snippet Preview
Preview how your page title and meta description appear in Google search.
Meta Tag Analyzer
Paste a page's HTML head to audit its title, meta, and social tags.