Add to Chrome Add to Edge

HTACCESS Redirect Generator

Write the Apache .htaccess rule that redirects an old page to a new URL with a 301, 302, 303 or 307.

Enter the path of the page you want to redirect from (e.g., /old-page)
Enter the path or URL you want to redirect to (e.g., /new-page or https://example.com/page)
Choose the type of redirect you want to use
Redirect Preview

This redirect will send visitors from:
➔


HTACCESS Redirect Generator

The .htaccess Redirect Generator writes the Apache rule that sends visitors and search engines from an old page to a new address. Enter the old path and the new URL, choose the redirect type, and copy a ready-to-paste mod_rewrite block for your site's .htaccess file. Special characters in the old path, such as the dot in .html, are escaped for you, so the rule matches exactly that page.

How to use the .htaccess redirect generator

  1. Enter the old path, starting with a slash, for example /old-page.html.
  2. Enter the new destination: another path on your site (/new-page) or a full URL (https://example.com/new-page).
  3. Choose the redirect type. Use 301 for a permanent move, which is what you want in almost every case.
  4. Click the button, copy the code and paste it near the top of the .htaccess file in your site's root folder.

Which redirect type to choose

  • 301 Moved Permanently: the page has moved for good. Search engines move the old page's ranking signals to the new URL. Use it for renamed pages, deleted pages with a close replacement, and domain moves.
  • 302 Found: a temporary redirect. Search engines keep the old URL in their index. Use it for short campaigns or maintenance.
  • 303 See Other: sends the visitor to another page after a form submission.
  • 307 Temporary Redirect: like 302, but the browser must repeat the same method (for example POST). Mostly for APIs and forms.

Our guide to 301 vs 302 redirects explains the difference for SEO in more detail.

Tips for safe redirects

  • Keep a backup of your current .htaccess before editing: one typo can take the whole site down with a 500 error.
  • Redirect each old page to its closest new equivalent, not everything to the homepage; Google treats mass homepage redirects like a missing page.
  • Avoid chains: point old URLs straight to the final destination, not through another redirect.
  • Test the result with the Redirect Checker and make sure it returns a single 301.
  • On nginx servers, .htaccess files are ignored; convert the rules with the .htaccess to nginx converter.

Frequently asked questions

Where is the .htaccess file?
In your website's root folder (often public_html). Its name starts with a dot, so it is hidden: enable "show hidden files" in your file manager or FTP program.
The redirect does not work. What should I check?
Make sure the server runs Apache or LiteSpeed with mod_rewrite enabled, that the old path matches exactly (including any trailing slash), and that no earlier rule in the file catches the request first. Clear your browser cache, because browsers remember 301 redirects.
Can I redirect a whole domain?
This generator writes one page-to-page rule at a time. To move a whole domain, use a rule that matches every path on the old domain and keeps the path, for example RewriteRule ^(.*)$ https://new.com/$1 [R=301,L] on the old domain's site.
Does a 301 redirect lose SEO value?
Google has said that 301 redirects pass ranking signals to the new URL. Keep the redirect in place for at least a year, ideally permanently.

Related guides

Choose which cookies SEOpeck may use. You can change this at any time from "Cookie settings" at the bottom of every page.

Your tools

    Saved in this browser only. Nothing is sent to us.

    Popular tools