Free SEO tool

.htaccess Redirect Generator

Choose the redirect type and fill in the paths. The generator writes the .htaccess rules for Apache servers, including 301 redirects, HTTPS and www rules.

What is .htaccess redirect generator?

Redirects send visitors and search engines from one URL to another. A 301 redirect tells search engines that the move is permanent, so most ranking signals pass to the new address.

Rewriting rules in .htaccess are easy to get wrong. This generator gives tested snippets for the most common jobs on Apache servers, which includes most shared hosting such as Hostinger.

How to use the .htaccess redirect generator

  1. Choose the type of redirect you need.
  2. Fill in the old path and new URL if the type needs them.
  3. Press Generate and paste the rules into your .htaccess file, above any existing WordPress rules.

How the .htaccess redirect generator works

Single redirects use the Redirect 301 directive. HTTPS, www and slash rules use mod_rewrite with RewriteCond and RewriteRule and a 301 status. Domain moves rewrite every path to the same path on the new domain.

Worked example

Redirect 301 /old-page/ https://example.com/new-page/ sends anyone who visits the old page to the new one with a permanent redirect.

Common uses of the .htaccess redirect generator

  • Moving pages after a redesign.
  • Forcing all traffic to HTTPS.
  • Choosing one canonical version, www or non www.
  • Fixing broken links by redirecting them.
  • Moving a site to a new domain.

Tips and common mistakes

Back up your .htaccess file first. A single typo can cause a server error.

Avoid redirect chains. Point old URLs straight to the final destination.

Background: what to know before you rely on it

Search engines treat a 301 as a signal that the old URL has moved permanently and that the new URL should replace it in the index. A 302 is temporary, so the old URL usually stays indexed. Redirect chains slow pages down and can lose signals, so link directly to the final address. Domain moves need extra care: redirect every old URL to its exact match, update canonical tags, sitemaps and internal links, and tell Google through the Change of Address tool in Search Console. After any redirect change, test with a few URLs, check the status codes and watch the Search Console coverage reports for errors.

Private, free and fast

This tool runs entirely in your browser. What you type or choose is not uploaded to a server and is not saved after you close the page, which keeps it fast and private. It is free to use as often as you like. See more in all seo tools, or browse the full list of tools.

Frequently asked questions

Where is the .htaccess file?

In the root of your site, often inside public_html.

What is a 301 redirect?

A permanent redirect that passes most SEO value to the new URL.

Does this work on Nginx?

No. Nginx uses a different syntax.

How long should I keep redirects?

At least a year, and ideally as long as the old URL still has links.

Related tools

Results are for information and education. For legal, financial, medical or security decisions, check with a qualified professional. Validate markup with search engine testing tools before publishing.