.htaccess Redirect Generator
Turn a list of old and new URLs into ready-to-paste Apache .htaccess 301 or 302 redirect rules.
Separate the two URLs with a space, tab, comma or ->. # lines
are ignored.
How it works
Paste your old and new URLs — one pair per line — and the generator writes the matching
Apache .htaccess rules instantly. Choose 301 for a permanent move (the one
that passes SEO value) or 302/307/308 for a temporary one, then pick the module you want:
mod_rewrite produces exact RewriteRule patterns, while
mod_alias produces the shorter Redirect lines. Source paths are
regex-escaped for you, so dots in filenames like /about-us.html cannot match
the wrong URL, and an optional trailing slash is always accepted.
The extra switches cover the rules almost every site needs: force HTTPS, and force or strip
the www prefix. Those canonical rules are always emitted as 301s (a permanent
canonical is what search engines expect) and are placed above your path redirects so they
run first. Wrapping everything in an IfModule guard keeps the file safe on
hosts where the module is missing. Copy the result, or download it and paste it at the top
of the .htaccess file in your site root — back up the original first, and test
one redirect in a private window before you trust the whole list.
Everything is generated in your browser with JavaScript. Your URL list is never uploaded, stored or logged, so a full site-migration map with unreleased URLs stays private.
Frequently asked questions
How do I create a 301 redirect in .htaccess?
Paste the old URL and the new URL on one line (separated by a space, tab, comma or ->), leave the type on 301, and copy the generated block into the .htaccess file in your site root. With mod_rewrite you get a rule like RewriteRule ^old-page/?$ /new-page [R=301,L]; with mod_alias you get the shorter Redirect 301 /old-page /new-page. This generator regex-escapes the old path for you, so dots in filenames such as /about-us.html cannot match the wrong URL, and it accepts an optional trailing slash.
What is the difference between a 301 and a 302 redirect?
A 301 is permanent: search engines drop the old URL from their index and transfer its ranking signals to the new one, and browsers cache it aggressively. A 302 is temporary: the old URL stays indexed and no ranking value moves. Use 301 for site migrations, renamed pages and removed URLs; use 302 for A/B tests, short-lived campaign pages or maintenance detours. Pick 307 or 308 instead if the redirect must preserve the original HTTP method and body, for example on a POST endpoint.
How do I force HTTPS or redirect www to non-www in .htaccess?
Tick "Force HTTPS" and set "Canonical host" to Force www or Remove www — the generator emits the matching RewriteCond and RewriteRule lines above your path redirects so they run first, and always uses a 301 because a canonical redirect should be permanent. Add only one canonical host rule per site (either www or non-www, never both) or you will create a redirect loop, and keep these rules ahead of any per-page redirects in the file.