BYTETOOLS

How to Generate .htaccess 301 Redirects Step by Step

To generate .htaccess redirects, list each old path and the new path it should point to, choose 301 (permanent) or 302 (temporary), optionally enable Force HTTPS and a www preference, then copy or download the ready-to-paste rules from the ByteTools Htaccess Redirect Generator. You get valid Apache mod_rewrite syntax without hand-writing a single line.

This guide walks through the full process — from adding your first redirect row to placing the file on your server and confirming it works.

What the generator produces

The tool turns a simple table of old-to-new URL pairs into an Apache .htaccess file. Alongside per-URL redirects it can add the two site-wide canonicalization rules SEOs use most: forcing every request onto HTTPS, and forcing a single hostname (either www or non-www). Everything is assembled live in your browser and downloads as a real .htaccess file — nothing is uploaded to a server.

Step-by-step walkthrough

  1. Add a redirect row. Enter the old path (for example /old-page) and the new path or full URL it should point to.
  2. Repeat for every URL. Add as many rows as you need — one per redirect you're setting up.
  3. Choose the redirect type. Pick 301 for permanent moves so search engines transfer ranking signals, or 302 for temporary changes you'll reverse later.
  4. Enable canonicalization (optional). Toggle Force HTTPS to push every visitor to the secure version, and choose Force www or Force non-www to enforce one hostname.
  5. Copy or download. Grab the generated rules with one click, or download the finished .htaccess file.
  6. Deploy and test. Upload the file to your site's root directory and visit an old URL in your browser to confirm it lands on the new one.

Where to put the file and how to test

The .htaccess file belongs in your site's root directory — the same folder as your main index file. The rules apply to that folder and everything below it. The name must be exactly .htaccess, with the leading dot and no extension. After uploading, open an old URL directly; a correct 301 will send you to the destination and browser dev tools will show a 301 Moved Permanently status.

GoalWhat to set
Permanently move a pageAdd a row, choose 301
Temporary A/B or maintenance redirectAdd a row, choose 302
Force secure connectionsEnable Force HTTPS
One canonical hostnameChoose Force www or non-www

Why generate it in the browser

The rules are assembled entirely client-side, so your URL list and site structure never leave your machine — useful when you're mapping out a migration that isn't public yet. It's free, requires no account, and works offline once loaded. You still get standard, portable mod_rewrite output that any Apache host will read.

Try the Htaccess Redirect Generator — free and 100% in your browser.

FAQ

Do I need to know mod_rewrite to use this?

No. You fill in old and new paths in plain form fields and the tool writes the RewriteRule and RewriteCond syntax for you. Knowing the basics helps you review the output, but it isn't required to generate working rules.

Does the generated file work on Nginx?

No — .htaccess and mod_rewrite are Apache features. Nginx uses a different configuration format. This tool targets Apache and Apache-compatible hosting (including shared hosting that uses Apache).

Can I mix 301 and 302 redirects in one file?

Yes. You can choose the status per configuration, so a single generated file can contain permanent 301s and temporary 302s together.

What happens if I don't add a leading slash to a path?

Paths are matched relative to your site root, so it's safest to enter them as the tool expects (for example /old-page). Review the generated rule and test in a browser to confirm the match behaves as intended.

Related free tools

Built by ByteVancer

ByteTools is a free product of ByteVancer, a software and web development studio building web apps, SaaS and custom software. If a site migration is part of a bigger project, explore how ByteVancer can plan and execute it cleanly.