Skip to content

.htaccess Redirect GeneratorNew

Make 301 redirects and HTTPS/www rules.

Runs in your browser · free · no sign-up

Preferred host
Redirect type
.htaccess (Apache)

About the .htaccess Redirect Generator

Moving pages or switching to HTTPS needs correct redirects so you keep your rankings. Pick what you need and copy tested Apache rules.

When you move pages, rename URLs, switch to HTTPS or choose between www and non-www, visitors and search engines need to be redirected to the new address. Without redirects, old links and bookmarks lead to 404 errors and search rankings built up over years can be lost. On Apache and LiteSpeed servers, which host most shared hosting accounts, redirects are written in the .htaccess file using mod_rewrite.

This generator builds those rules for you. Enter your domain and choose site-wide rules: force HTTPS, force www or non-www, and remove trailing slashes. Then list page redirects as pairs of old and new paths, one per line, and choose 301 (permanent) or 302 (temporary). The output is ready to paste into .htaccess.

Each rule uses Apache’s mod_rewrite, the module almost every shared host enables. The generated block starts with RewriteEngine On so it can be pasted into an empty file, or placed near the top of an existing .htaccess before other rewrite rules such as those added by WordPress.

How to use the .htaccess Redirect Generator

  1. 1Add old and new URLs, or pick a site-wide rule.
  2. 2Choose 301 (permanent) or 302 (temporary).
  3. 3Copy the code into your .htaccess file.

Key features

  • Force HTTPS.
  • Force www or non-www.
  • Remove trailing slashes.
  • Page-to-page redirects.
  • 301 or 302 status codes.

Practical uses

  • Redirecting old URLs after a site redesign.
  • Moving a site from HTTP to HTTPS.
  • Standardising on www or non-www.
  • Redirecting deleted products to similar ones.

Example

The pair “/old-page /new-page” with 301 selected produces a rule that permanently sends visitors and search engines from example.com/old-page to example.com/new-page.

Tips and common mistakes

  • Back up your existing .htaccess before editing.
  • Avoid redirect chains; point old URLs straight to the final page.
  • Test redirects in a private window to avoid cached results.

Limitations

  • Nginx and IIS use different configuration formats.
  • Complex pattern-based redirects need manual rules.

Privacy

Rules are generated in your browser.

Frequently asked questions

Which servers use .htaccess?

Apache and LiteSpeed. Nginx uses its own config files instead.

Should I use 301 or 302?

Use 301 for permanent moves so search engines pass ranking to the new URL.

Where does the code go?

In the .htaccess file in your site’s root folder; back it up first.

Why does my site show “too many redirects”?

Usually two rules or a CDN setting send traffic back and forth. Check your hosting and Cloudflare SSL settings as well as .htaccess.

How long should 301 redirects stay in place?

Ideally permanently, or at least a year, so search engines and old links keep finding the new page.

Related tools

Meta Tag GeneratorNewCreate SEO, Open Graph and Twitter tags.
Robots.txt GeneratorNewBuild a robots.txt, incl. AI crawler blocking.
XML Sitemap GeneratorNewTurn a list of URLs into sitemap.xml.
UTM Link BuilderNewAdd UTM tracking tags to campaign links.