Websites from ₹4,999 · Apps from ₹24,999 · 100 free tools

Free tool · Developer tools

.htaccess Redirect Generator

This .htaccess redirect generator writes correct 301 or 302 redirect rules for single pages or long lists of URLs, plus force HTTPS, www and trailing slash rules, with the Nginx version alongside.

Separate the two columns with a space, tab or comma. You can paste two columns straight from Excel or Google Sheets. Lines starting with # are skipped.

Before you change .htaccess:
  • Download a backup of your current .htaccess file first. One wrong line can show a "500 Internal Server Error" on the whole site; restoring the backup fixes it.
  • On WordPress, paste these rules above the # BEGIN WordPress line. WordPress rewrites everything between # BEGIN WordPress and # END WordPress, so rules placed inside that block can be lost.
  • Test the old URLs in a private window. Browsers remember 301 redirects, so test with 302 first if you are unsure.

Everything runs in your browser. Nothing you type is sent anywhere, and it is cleared when you close this page.

Free · no sign-up · runs in your browser, nothing is uploaded

Need help fixing it?

Get a free website audit from our team

Our developers check your site's speed, SEO and mobile experience and send you a short list of fixes. No charge, no obligation.

  • Reply on WhatsApp or call, your choice
  • Websites from ₹4,999, apps from ₹24,999

Request free audit

We reply within a few working hours. No spam.

Why you need redirects

When you change a page address, move to a new domain or rebuild your website, the old links do not disappear. Google still has them, other sites still link to them and customers may have them bookmarked. Without a redirect, every one of those visitors lands on a “404 Not Found” page. A 301 redirect sends people and search engines to the new address and tells search engines that the move is permanent.

How to use the .htaccess redirect generator

  1. Type or paste your redirects, one per line: the old path first, then the new URL. You can paste two columns straight from Excel or Google Sheets.
  2. Choose 301 (permanent) or 302 (temporary). Use 302 while testing.
  3. Tick extra options if you need them: force HTTPS, remove or add www, remove or add the trailing slash, or move the whole site to a new domain.
  4. Fix any lines the tool marks in red, such as an old path that does not start with /.
  5. Copy the Apache rules for your .htaccess file, or switch to the Nginx tab if your server runs Nginx.

Where to paste the rules

Download a copy of your current .htaccess file first, so you can restore it in seconds if anything goes wrong. On WordPress, paste the rules above the line # BEGIN WordPress. WordPress manages the block between # BEGIN WordPress and # END WordPress and can rewrite it when you save your permalink settings, so rules inside that block may disappear. Rules that sit above it also run before WordPress handles the request.

Nginx does not read .htaccess files. Add the Nginx lines to the server block for your site, run nginx -t to test the configuration and reload Nginx. On shared hosting with Nginx, ask your host to add them.

Tips

  • Redirect each old page to the closest matching new page, not everything to the home page.
  • Avoid chains such as A to B to C. Point A straight to C.
  • Browsers remember 301 redirects. Test in a private window, and check the result with our redirect checker.
  • The generator escapes dots, spaces and other special characters for you, so a path like /about.html matches only that page.

This .htaccess redirect generator creates the rules in your browser. Nothing you type is sent to our server.

FAQ

.htaccess Redirect Generator: FAQs

What is the difference between a 301 and a 302 redirect?

A 301 says the page has moved permanently, so search engines treat the new address as the main one. A 302 says the move is temporary. Use 301 for changed URLs and domain moves, and 302 for short tests or temporary pages.

Where do I put these rules in WordPress?

Open the .htaccess file in your site's main folder (with your host's file manager or FTP) and paste the rules above the "# BEGIN WordPress" line. Keep a backup of the original file.

My site shows "500 Internal Server Error" after adding the rules. What now?

Restore your backup .htaccess file and the site comes back at once. Then check that your host supports mod_rewrite and that you copied the full block, including the IfModule lines.

Can I redirect URLs that have a ?query string?

Yes. Enter the old URL with its query, for example /product.php?id=12. The generator adds a RewriteCond for the query string and drops the old query from the new URL.

Do I need the Nginx version?

Only if your server runs Nginx instead of Apache. Many shared hosting plans run Apache or LiteSpeed, which read .htaccess. If you are unsure, ask your hosting provider.

More free tools

You might also like

New

Split PDF & Extract Pages

Split a PDF or extract only the pages you need. Remove pages, save every page as a separate PDF, or split every…

PDF tools

See all free tools

Have a project in mind?

Tell us what you want to build. You get ideas, a timeline and a clear quote, free.

Chat on WhatsApp