.htaccess Redirect Generator
FreeGenerate Apache .htaccess redirect rules instantly. Create 301 and 302 redirects, directory redirects, and regex URL rewrites for Apache servers.
What's next
Settings guide
Simple Redirect directive:
Redirect 301 /old-page.html https://yourdomain.com/new-page
Best for exact URL mappings. Works without mod_rewrite enabled. The source path is relative (no domain); the destination is absolute.
RewriteRule format:
RewriteRule ^old-path/?$ /new-path [R=301,L]
The R=301 flag sets the status code. L means "stop processing rules here." The ? after the slash makes the trailing slash optional.
Common RewriteRule flags:
- ·
[R=301,L]— Permanent redirect, stop processing - ·
[R=302,L]— Temporary redirect, stop processing - ·
[NC]— Case-insensitive matching - ·
[QSA]— Append existing query strings to the new URL
Required directives at the top:
Any file using RewriteRule must begin with RewriteEngine On. If your .htaccess is in a subdirectory, add RewriteBase /subdirectory/.
HTTPS force redirect:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Format comparison
.htaccess vs Nginx redirects:
.htaccess is Apache-specific and applies per-directory without requiring server restart. Nginx does not support .htaccess — Nginx redirects are configured in the server block configuration files and require a server reload. If your host runs Nginx, use the Nginx format in the redirect builder instead.
.htaccess vs Vercel redirects:
Vercel uses a JSON configuration file (vercel.json) for redirects, not .htaccess. If you are deploying to Vercel, Netlify, or similar serverless platforms, .htaccess rules will be ignored — use the platform-specific format generator instead.
How it works
Enter your redirect pairs
Add source paths and destination URLs for each redirect you need to create.
Choose directive type
Select simple Redirect directive for exact URLs, or RewriteRule for pattern-based redirects with regex.
Set redirect type
Choose 301 (permanent) or 302 (temporary) based on whether the move is permanent.
Copy to your .htaccess file
Add the generated rules to your .htaccess file on your Apache server and test each redirect.
About this format
Apache's .htaccess file is the configuration layer that controls redirects, URL rewrites, access rules, and caching headers for Apache web servers. WordPress, many PHP applications, and a large portion of shared hosting environments run on Apache — making .htaccess knowledge essential for anyone managing SEO on these platforms.
Writing .htaccess redirect rules by hand is error-prone. A single syntax mistake — a missing slash, a wrong flag, or an incorrect regex — can cause redirect loops, broken URLs, or accidentally expose server paths. This generator produces verified .htaccess redirect syntax using both the simple `Redirect` directive and the more powerful `mod_rewrite` `RewriteRule` format.
Use the simple `Redirect` directive for exact URL-to-URL redirects. Use `RewriteRule` for pattern-based redirects: forcing trailing slashes, removing index.html from URLs, redirecting all HTTP traffic to HTTPS, redirecting entire subdirectories, or normalizing URL parameters. Both formats are generated with correct flags and tested syntax.