htaccess 301 Redirect Generator

Generate ready-made 301 redirect rules for your .htaccess file.

🔒 All processing happens in your browser — your files are never uploaded to a server.

About .htaccess Redirect Generator

When you rename a page or move it, the old URL does not disappear. It lives on in search results, in links from other sites and in visitors' bookmarks. Leave it alone and people land on a 404 error, while the ranking signals that page earned quietly go to waste. On Apache servers the standard fix is a permanent (301) redirect in your .htaccess file: anyone requesting the old address is sent to the new one automatically, and search engines learn that the move is permanent.

This tool writes that rule for you in the correct syntax. Write one redirect per line, the old path, a space, then the new URL, with as many lines as you need, and choose permanent (301) or temporary (302). You can also force HTTPS for the whole site and settle on one domain form by always adding or always removing www. The rules appear ready to copy with the Copy button and paste into .htaccess, and any line that is not valid is pointed out. It suits site owners, bloggers and developers who want a correct rule without having to remember the exact format.

Why use it

  • Produces the Redirect 301 directive with the right order and spacing.
  • A 301 tells search engines the move is permanent, so the old page's value can pass to the new one over time.
  • A Copy button puts the rule on your clipboard, ready to paste.
  • Works in the browser with no account and no access to your hosting panel.
  • Useful on any Apache-based host, including most shared hosting plans.

How to use

  1. Write the redirects

    In the box, put one redirect per line: the old path, a space, then the new URL, for example /old-page https://example.com/new-page. The old path starts with a slash.

  2. Choose the type and options

    Pick 301 for a permanent move or 302 for a temporary one, and tick Force HTTPS or choose a domain form if you need them.

  3. Click Generate code

    The rules appear ready to use, with a message about any line that was skipped as invalid. Copy them with the Copy button.

  4. Add them to .htaccess

    Open .htaccess in your site's root folder through your host's file manager or FTP, paste the rules and save after making a backup.

  5. Test it

    Open the old URL in a private window and confirm it lands on the new page.

Examples

Renaming a blog post

You changed /blog/seo-tips-2024 to https://example.com/blog/seo-tips. Type /blog/seo-tips-2024 https://example.com/blog/seo-tips on one line and the rule is ready.

Merging two similar pages

Two service pages were competing for the same keyword, so you combined them. Redirect the one you removed to the page you kept.

Moving a section to a new domain

Your shop moved to its own domain. On the old site, a rule sends /shop to https://newstore.com/shop.

A discontinued product

Instead of letting a deleted product page return 404, point it at its category page or the closest replacement.

Common HTTP redirect and error codes
CodeMeaningWhen to use it
301Moved permanentlyA URL changed for good or a site moved domains
302Found (temporary)Maintenance or a short campaign; the original returns later
410GoneContent removed with no suitable replacement
404Not foundWhat visitors see when there is neither a page nor a redirect

Tips

  • Write the old path without the domain and starting with a slash; write the new URL in full, including https.
  • Redirect matches the start of the path, so redirecting /blog also catches /blog/post and appends the rest to the new URL. Choose paths carefully.
  • Back up .htaccess before editing; one broken line can take the whole site down.
  • Send each old page to its closest equivalent rather than dumping everything on the homepage.
  • Avoid chains: if A goes to B and B goes to C, point A straight at C.
  • This directive is for Apache. Nginx ignores .htaccess files and needs its own configuration.

The rule is generated in your browser; the URL you type is not sent to any server.

Frequently asked questions

What is a 301 redirect?

It is a server response that tells browsers and search engines a page has moved permanently. Visitors are forwarded automatically, and search engines gradually move their index to the new URL.

What exactly does this tool output?

One Redirect 301 /old-page https://… line (or 302) for each redirect you wrote, plus the RewriteEngine rules for HTTPS or the www form when you turn those on.

Where is my .htaccess file?

Usually in your site's root folder, such as public_html. Its name starts with a dot, so enable hidden files in your file manager. If it does not exist, you can create it with that exact name.

Will this work on any host?

It works on Apache and compatible servers like LiteSpeed, provided your host allows .htaccess overrides. Nginx, Netlify and Vercel use other redirect methods.

Does a 301 hurt my rankings?

Used properly, it is the recommended way to preserve a moved page's value. Problems come from piles of 404s or from redirecting pages to unrelated content.

How long until search results show the new URL?

Visitors are redirected the moment you save the file. Search engines need to recrawl the old URL, which can take anywhere from days to a few weeks.

Can I add multiple redirects?

Yes. Generate one rule per page and put each on its own line in .htaccess.

What is the difference between 301 and 302?

301 means permanent and 302 means temporary. Use 301 when the old URL is not coming back, because it signals search engines to adopt the new address.

Do I include the domain in the old path?

No. Use only the part after the domain, such as /about-us. The destination, on the other hand, should be the full URL with https.

My site shows a server error after editing. Why?

Most likely a typo in the file. Restore your backup, then make sure the rule sits on its own line with single spaces between its parts.

Can I redirect an entire site to a new domain?

Yes. Redirect 301 / followed by the new domain forwards every URL and keeps the rest of the path, so the new site needs a matching URL structure.

Is anything I type saved?

No. Everything happens in your browser and nothing is stored or transmitted.

Last updated:

Share this tool:WhatsAppXTelegram