.htaccess Redirect Generator
Runs in your browserGenerate .htaccess rules for 301/302 redirects, forcing HTTPS, and normalising the www subdomain — for Apache servers.
.htaccess
RewriteEngine On
# Force HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirects
Redirect 301 /old-page /new-page
About this tool
A wrong or missing redirect is one of the most common ways a site loses SEO value during a migration or restructure: old URLs that just 404 instead of pointing to their replacement, or a site reachable at both www and non-www with no canonical winner, which search engines treat as duplicate content. This tool builds the mod_rewrite rules Apache needs for the three most common fixes: page-to-page redirects, forcing HTTPS, and picking one www variant.
How to use
- List old-to-new path pairs, one per line, separated by a space.
- Toggle force-HTTPS and choose a www mode if you need them.
- Copy the result into your site's .htaccess file, in the root directory.
When to use this tool
- Redirecting old URLs to their new location after a site restructure.
- Forcing every visitor onto HTTPS.
- Picking a single canonical host — www or non-www — for SEO.
Tips
- Always back up your existing .htaccess before replacing it — a bad rewrite rule can take your whole site down.
- Use 301 for permanent moves and 302 only for genuinely temporary redirects; search engines treat them very differently.
Limitations
- Only Apache's mod_rewrite syntax — Nginx and other servers use different configuration formats entirely.
FAQ
- Does this work on Nginx?
- No. .htaccess and mod_rewrite are Apache-specific. Nginx uses a completely different configuration syntax.
- Where does this file go?
- In the root directory your Apache server serves from, as a file literally named .htaccess.