#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
↪️ FREE · APACHE

.htaccess Redirect Generator: Move Pages Without Losing Visitors

List old and new URLs and get mod_rewrite rules ready for your .htaccess file.

  • 🔁 301, 302 and 308
  • 🔒 HTTPS and www in one go
  • 🛑 Catches self-redirects

How to use the .htaccess Redirect Generator

  1. 1. List redirectsEach line: the old path, a space, then the new path or full URL.
  2. 2. Choose site rulesForce HTTPS, and pick www or non-www, with your domain.
  3. 3. Add and testBack up .htaccess, paste the rules near the top and test each old URL.

What the example generates

The three sample redirects become RewriteRule lines such as RewriteRule ^old-page\.html$ /new-page/ [L,R=301]. Dots and other special characters in the old path are escaped so they match literally, and the ^ and $ anchors make sure /old-page.html does not also catch /old-page.html-backup. Above them sit two site rules: one sends example.com to www.example.com, and one sends any HTTP request to HTTPS, both straight to the final host so visitors hit a single redirect, not a chain.

If an old path includes a query string, such as /page?id=7, the tool adds a RewriteCond for it, because RewriteRule alone never sees the query part.

Before you upload

  • These rules need Apache with mod_rewrite and AllowOverride enabled. Nginx ignores .htaccess; use a return 301 inside a server block instead.
  • Back up the current file. One typo can make the whole site return a 500 error.
  • Use 301 or 308 only for permanent moves, because browsers cache them for a long time.
  • Redirect each old page to its closest new page, not everything to the home page.

If you use WordPress, put these rules above the # BEGIN WordPress block. Test old URLs in a private window to avoid cached redirects. Update internal links and the sitemap afterwards with the XML sitemap generator, and set canonicals with the canonical tag generator. For Nginx servers, start from the Nginx config generator.

Frequently asked questions

Why use RewriteRule instead of Redirect 301?

RewriteRule handles exact matching, query strings and host rules in one consistent system. Mixing Redirect and RewriteRule can run in an unexpected order.

How many redirects can .htaccess hold?

Hundreds are fine. For many thousands, a RewriteMap in the server config is faster, because .htaccess is read on every request.

Is the .htaccess Redirect Generator free?

Yes, the .htaccess Redirect Generator is free. The first time you generate your first rules, you are asked for your name and WhatsApp number once. After that, this and every other Uncodemy tool opens straight away without the form.

More free tools

See all free tools