Rankite
ServicesResultsToolsTeamAboutBlogCareersContactFree SEO Audit
Free tool

Htaccess Redirect Generator: 301 and 302 Redirects

Paste your old and new URLs, pick 301 or 302, and copy a clean, ready-to-use Apache .htaccess snippet in seconds.

Home / Tools / Htaccess Redirect Generator
Your .htaccess snippet

Always back up your existing .htaccess before editing. These rules apply to Apache servers only and a single typo can take a site offline.

Built by Rankite, the SEO team behind Swordfish AI's +400% revenue and Zluri's +45% organic growth. See the case studies

A redirect tells browsers and search engines that a URL has moved and points them to its new home. On Apache servers you set this up in the .htaccess file using either a permanent 301 or a temporary 302. The generator above writes those rules for you from a simple list of old and new URLs, with optional blocks to force HTTPS and standardize www. Below is what each option does and how to avoid the mistakes that quietly cost rankings.

301 vs 302 redirects

The difference comes down to permanence. A 301 is a permanent redirect: it tells search engines the old URL is gone for good, so they should drop it from the index and pass its accumulated link equity to the new URL. This is what you want for almost every real move, such as a renamed page, a restructured URL or a domain migration. A 302 is a temporary redirect. It signals that the move is short-lived, so engines keep the original URL indexed and do not transfer authority to the destination.

Reach for a 302 only when the change really is temporary: an A/B test, a country-specific landing page, a seasonal promotion that will revert, or maintenance routing. Using a 302 for a permanent move is a common and costly error, because the new page never inherits the old page's rankings. When in doubt for a move you expect to keep, choose 301.

How to add redirects in .htaccess

The .htaccess file lives in the root directory of your site, usually the public_html or www folder on your Apache host. It is a hidden file, so you may need to enable hidden files in your FTP client or hosting file manager before you can see it. If one does not exist, you can create a plain text file named exactly .htaccess with no extension.

Back up the current file first by downloading a copy you can restore. Then paste the generated rules, ideally near the top, and save. Test a couple of the old URLs in a private browser window to confirm they land on the right destinations. These directives only work on Apache: if your site runs on Nginx, IIS or Caddy, the syntax will not apply and you will need that server's own redirect configuration instead.

Redirect mistakes that hurt SEO

A few patterns turn a helpful redirect into a ranking problem. Redirect chains, where URL A points to B which points to C, waste crawl budget and slowly leak link equity at every hop, so always send the old URL straight to its final destination. Redirect loops, where two rules point at each other, make a page unreachable and throw a browser error. Redirecting every old URL to the homepage is another quiet killer: it looks tidy but is treated as a soft 404, so the old page's rankings evaporate instead of transferring. Map each old URL to the closest matching new page so authority flows where it belongs. Finally, double-check you are using 301 rather than 302 for permanent moves, since the wrong status code is one of the easiest ways to lose hard-won rankings without noticing.

Related articles

FAQ

Htaccess Redirect Generator: questions, answered

What is the difference between a 301 and a 302 redirect?
A 301 is a permanent redirect and a 302 is a temporary one. Use 301 when a page has moved for good, because it passes nearly all link equity and tells search engines to index the new URL. Use 302 only for short-term moves like an A/B test or a seasonal page, since it keeps the old URL indexed.
Where do I put .htaccess redirect rules?
Place the rules in the .htaccess file in the root directory of your site, usually the public_html or www folder on an Apache server. The file may be hidden, so enable hidden files in your FTP client or file manager. Back up the existing file before you paste anything, because a single typo can take the whole site offline.
Does this generator work on Nginx or other servers?
No. The .htaccess file and its Redirect and RewriteRule directives are specific to the Apache web server. Nginx, IIS and Caddy use their own configuration syntax, so the output here will not work on them. Check with your host if you are unsure which server you run.
Will redirects hurt my SEO?
Done correctly, 301 redirects protect SEO by sending users and link equity from old URLs to the right new ones. Problems start with redirect chains, redirect loops, redirecting everything to the homepage, or using 302s for permanent moves. Map each old URL to its closest matching new URL to keep rankings intact.
Can I redirect a whole domain to a new one?
Yes. The simplest path-level rules here handle page-to-page moves, while the force HTTPS and non-www to www options use RewriteRule blocks that redirect every request. For a full domain migration, redirect each old URL to its matching page on the new domain rather than dumping all traffic on the new homepage.

More free tools

Let's grow

Ready to own page one?

Get a free, no-obligation SEO audit and a 30-minute strategy session. We'll show you exactly where the growth is hiding.

Book your free audit Explore services
Get in touch

Tell us about your project

Fill out the form and we'll get back to you within one business day. Prefer email? Write to us directly at contact@rankite.com.

Or copy our email and write to us directly: contact@rankite.com