.htaccess 301 Redirect Generator

Create 301 redirects, force HTTPS and set www or non-www for Apache and most WordPress hosting.

Bilal KhizriFree tool by Bilal Khizri · No sign-up · Works on mobile
💡 In simple words: When you move or rename a page, people and Google may still go to the old address and see an error. A redirect automatically sends them to the new page instead, like forwarding your post to a new house. This tool writes the redirect code for you.

How to use the .htaccess redirect generator

  1. List your redirects: the old path, a space or comma, then the full new URL.
  2. Choose whether to force HTTPS and www or non-www.
  3. Copy the code. Back up your existing .htaccess file (in your site’s root folder, via File Manager or FTP).
  4. Paste the code at the top of .htaccess, above “# BEGIN WordPress”, and save. Test the old URLs in a private browser window.

301 vs 302 redirects

When do you need redirects?

Avoid these redirect mistakes

On Nginx or LiteSpeed-only setups .htaccess may not work. On WordPress you can also use the Redirections module in Rank Math.

Frequently Asked Questions

Where is the .htaccess file?

In the root folder of your website (often public_html). It starts with a dot, so turn on “show hidden files” in your file manager.

Will redirects keep my Google rankings?

A 301 redirect to a closely matching page passes almost all ranking value to the new URL.

How long should I keep 301 redirects?

Keep them for at least a year, and ideally permanently, especially if other websites link to the old URLs.

Can I break my site by editing .htaccess?

A mistake can cause a 500 error. Always keep a backup so you can restore it in seconds.

Related Free Tools