Htaccess Redirect
Free Htaccess Redirect Generator to create error-free Apache 301 and 302 redirect code for pages, directories, www, and HTTPS.
Share on Social Media:
The .htaccess Redirect Generator creates clean, error-free Apache redirect code — 301 or 302, for a single page, a directory, www/non-www, or HTTP to HTTPS. Pick your redirect, enter the URLs, and copy ready-to-paste code into your .htaccess file, avoiding the typos that cause 500 errors and redirect loops. Free, with no signup.
Redirect Without Risking a Broken Site
Writing .htaccess rules by hand is risky — one misplaced character can trigger a server error or a redirect loop that takes your site offline. This generator removes that danger by producing standard-compliant Apache code for common redirect scenarios. You describe what you want; it writes the correct rule.
How to Use It
- Choose a redirect type — page, directory, www, or HTTPS.
- Enter your URLs and status — source, destination, 301 or 302.
- Copy into .htaccess in your site's root directory.
301 vs. 302: Choose Correctly
This choice has real SEO consequences. A 301 is permanent — it tells search engines the page has moved for good, transfers ranking signals (link equity) to the new URL, and is what you want for migrations and permanent changes. A 302 is temporary — it signals a short-term move, so search engines keep the old URL indexed and don't pass full ranking power. The rule of thumb: use 301 for permanent moves, and 302 only when the original URL will genuinely return.
Common Redirects It Handles
- Single page — send one old URL to its new home.
- Directory — redirect a whole folder of URLs.
- HTTP to HTTPS — force secure connections, good for security and SEO.
- www / non-www — pick one canonical host to avoid duplicate content.
Where the Code Goes
Paste the rules into the .htaccess file in your site's root directory — usually public_html, www, or htdocs. They apply to that directory and everything below it. The filename must be exactly .htaccess (leading dot, no extension), saved as plain text. You can also drop additional .htaccess files into subdirectories to add or override rules for just that section.
An Honest Caveat: Apache Only
A crucial point: .htaccess works only on the Apache web server (and Apache-compatible servers like LiteSpeed). Nginx does not use .htaccess — it handles redirects in its own server configuration with entirely different syntax. So before pasting generated code, confirm your site runs on Apache; on Nginx, these rules simply won't take effect.
Best Practices to Avoid Trouble
- Back up first — a single bad directive can 500 your whole site; test on staging if possible.
- Map smartly — send each old URL to its closest new equivalent, not all to the homepage.
- Keep chains short — ideally one hop, never more than three.
- Test in incognito — browsers cache 301s aggressively, so a private window avoids stale results.
Done right, 301 redirects are recommended by Google for migrations and protect your SEO. Free, with no signup.
Htaccess Redirect FAQs
What is an .htaccess redirect generator?
It creates the Apache configuration code that redirects one URL to another, without you having to write error-prone rules by hand. You choose the redirect type, enter your source and destination, pick a status code, and the tool outputs ready-to-paste code for your .htaccess file. It prevents the typos that can cause 500 errors or redirect loops.
What's the difference between a 301 and 302 redirect?
A 301 is permanent: it tells search engines the page has moved for good, transfers ranking signals (link equity) to the new URL, and is what you want for site migrations and permanent changes. A 302 is temporary: it signals the move is short-term, so search engines keep the old URL indexed and don't pass full ranking power. Use 301 for permanent moves and 302 only when the original URL will return.
Where do I put the .htaccess code?
In the .htaccess file in your website's root directory — commonly called public_html, www, or htdocs. The rules apply to that directory and everything beneath it. The filename must be exactly .htaccess (a leading dot, no extension), saved as plain text. You can also place additional .htaccess files in subdirectories to add or override rules for just that section.
Does .htaccess work on Nginx?
No — .htaccess is specific to the Apache web server (and Apache-compatible setups like LiteSpeed). Nginx doesn't use .htaccess files; it handles redirects in its server configuration with different syntax. So before using generated .htaccess code, confirm your site runs on Apache; otherwise the rules simply won't take effect.
How do I redirect HTTP to HTTPS, or www to non-www?
These are common domain-wide rules the generator handles. Forcing HTTPS redirects all insecure requests to the secure version, which is good for security and SEO. Choosing www or non-www picks one canonical version of your domain so search engines don't treat both as separate sites, avoiding duplicate-content issues. The tool produces the correct rule for whichever you choose.
Will redirects hurt my SEO?
Properly implemented 301 redirects won't hurt — in fact, Google recommends them for site migrations because they preserve ranking signals. The keys are to use 301 for permanent moves, map each old URL to its closest relevant new page (rather than dumping everything on the homepage), and keep redirect chains short. Done right, redirects protect your SEO during changes.
What should I be careful about?
A few things. Always back up your existing .htaccess first, because a single bad directive can take your whole site down with a 500 error — test on a staging site if you can. Keep redirect chains short (ideally one hop, never more than three). And remember browsers cache 301 redirects aggressively, so test in a private/incognito window to avoid seeing a stale cached redirect.
Is the tool free?
Yes, it's free with no signup. Choose your redirect, enter the URLs, and copy the generated .htaccess code.