Htaccess Redirect Generator
Htaccess Redirect Generator
Build .htaccess 301/302 redirect rules.
SEO Tools › Technical SEO › Htaccess Redirect Generator
Build .htaccess 301/302 redirect rules. It runs in your browser: nothing you paste is uploaded, there is no account, and the tool is free. It is built and maintained by SEO ProCheck.
Htaccess Redirect Generator
You changed a URL and the old one now leads nowhere
When a page moves, the old address should send people and crawlers to the new one with a proper status code. On Apache hosting (and servers that read Apache rules, such as LiteSpeed), that usually means a line or two in the .htaccess file at the site root. This generator writes those lines. It never connects to your server, so testing stays your job.
Step by step
- Open Redirect Type and select one of the seven options: 301 Permanent Redirect, 302 Temporary Redirect, Force HTTPS, Force WWW, Remove WWW, Add Trailing Slash, or Remove Trailing Slash.
- For the first two, type the path being retired into Old URL Path (just the part after the domain, beginning with /) and the destination into New URL.
- Press Generate Code and review what appears.
- Press Copy, save a copy of the original .htaccess, add the code, and request the old URL to confirm it returns a 301 or 302 to the right place.
What to watch for
The single redirect options use Apache's Redirect directive. It works on path prefixes: everything below the old folder follows it to the matching spot under the new one. If you need one exact URL only, you would need RedirectMatch or a RewriteRule with anchors, which this tool does not write. The fields are not validated either; leaving one empty produces an incomplete line that Apache will most likely reject.
The five site-wide options each output their own RewriteEngine On line plus conditions. You only need that switch once per file. Their targets are hard coded to https, and the trailing slash rules skip real files (adding) or real directories (removing) so stylesheets and folders are left alone. On WordPress, place custom rewrite rules above the # BEGIN WordPress section.
Chains are the quiet cost of stacking rules. Order the host rule (www or non-www) above Force HTTPS so an old http link resolves in a single redirect rather than two.
Questions people ask
Should I use 301 or 302?
Use 301 when the move is permanent, which covers most migrations and URL changes. Use 302 only when you plan to bring the old URL back.
Will this work on Nginx or IIS?
No. Nginx does not read .htaccess files, and IIS uses web.config. You would need to translate the logic into that server's own configuration.
Why did my whole site go down after pasting?
A malformed line in .htaccess makes Apache answer with a 500 Internal Server Error. Restore your backup, then check the pasted rule for missing values or stray characters.
Further reading: Redirect Chains and Loops: Why They Hurt and How to Fix Them and HTTP Does Not Redirect to HTTPS: How to Force HTTPS.
The same tool is also published on the static mirror at seoprocheck.github.io, and the rest of the set is on the free tools page.
