.htaccess Redirect Generator

Instantly generate .htaccess redirect rules for Apache servers — free, no login required. Supports 301, 302, 303 & 307 redirects.

Generated Code:

Your code will appear here

Free .htaccess Redirect Generator for Apache Servers

This free .htaccess redirect generator creates ready-to-paste Apache redirect rules in seconds. Whether you're migrating a domain, restructuring URLs, or fixing broken links, just enter your old and new URL, choose a redirect type, and copy the output directly into your .htaccess file. No account needed, no limits, works instantly.

What Is a .htaccess File?

A .htaccess file (short for Hypertext Access) is a server configuration file used by Apache web servers. Placed in your site's root directory, it controls how the server handles incoming requests — including URL redirects, password protection, custom error pages, and more.

Most shared hosting providers (Hostinger, Bluehost, SiteGround, GoDaddy) and popular CMS platforms like WordPress, Joomla, and Magento run on Apache, making .htaccess the go-to method for managing redirects without touching server configuration files directly.

How to Use This .htaccess Redirect Generator

  1. Enter the old URL — the path you want to redirect away from (e.g. /old-page.html or /blog/2020/post).
  2. Enter the new URL — where visitors should land (e.g. /new-page or a full URL like https://example.com/new-page).
  3. Choose your redirect type — use 301 for permanent moves, 302 for temporary ones.
  4. Click Generate and copy the output.
  5. Paste into your .htaccess file — connect via FTP or File Manager in cPanel, open the file in your site's root directory, and paste the code at the top (above any WordPress rules).
  6. Test the redirect using a browser or a tool like httpstatus.io to confirm it works.

301 vs 302 vs 307 — Which Redirect Should You Use?

Choosing the wrong redirect type is one of the most common SEO mistakes. Here's exactly when to use each one:

Code Name When to Use Passes SEO Value?
301 Permanent Redirect Page moved forever, domain migration, URL restructuring Yes — full link equity transferred
302 Temporary Redirect Site maintenance, A/B testing, seasonal pages No — original URL keeps its value
303 See Other After a form submission (POST → GET redirect) No
307 Temporary (Strict) Temporary redirect that must preserve the HTTP method No

Default recommendation: Use 301 in almost every real-world scenario. It tells Google to permanently update its index and passes the full ranking power (link equity) of the old page to the new one.

Common .htaccess Redirect Use Cases

1. Domain Migration

Moving from old-domain.com to new-domain.com? Add 301 redirects for every URL so Google transfers your rankings to the new domain. Without redirects, your new site starts from zero.

2. HTTP to HTTPS

If your site moved to SSL but users still land on http:// URLs, a redirect forces all traffic to the secure version. This also prevents duplicate content issues between the two versions.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

3. www to non-www (or vice versa)

Google treats www.example.com and example.com as two different sites. Pick one version and redirect the other to it to consolidate all your traffic and SEO authority.

4. URL Restructuring

Redesigning your site and changing URL structure? Redirect every old URL to its new equivalent. This preserves inbound backlinks and prevents visitors hitting 404 error pages.

5. Removing /index.html

Old sites often had /index.html in URLs. Redirect these to the clean version (/) to remove duplication.

Best Practices for .htaccess Redirects

Frequently Asked Questions

Does a 301 redirect hurt SEO?

No. A properly implemented 301 redirect passes nearly all of the original page's ranking power to the new URL. Google officially recommends 301 redirects for permanent page moves. Your rankings typically transfer within a few weeks.

How do I access my .htaccess file?

Connect via FTP (using FileZilla) or use the File Manager in cPanel. The file is in your site's root directory (usually public_html). It may be hidden — enable "show hidden files" in your FTP client. If no .htaccess file exists, create a plain text file named .htaccess (with no file extension).

Can I add multiple redirects in one .htaccess file?

Yes. You can have as many redirect rules as you need in a single .htaccess file. Just add each rule on a new line. For large sites with hundreds of redirects, consider a database-driven redirect plugin (like Redirection for WordPress) which handles large volumes more efficiently.

What's the difference between Redirect and RewriteRule in .htaccess?

Redirect (from mod_alias) is simpler and good for basic page-to-page redirects. RewriteRule (from mod_rewrite) is more powerful — it supports pattern matching, conditions, and query string handling. For most use cases, Redirect 301 /old /new is sufficient. Use RewriteRule when you need conditional logic or regex matching.

How long does it take Google to recognize a 301 redirect?

Google typically processes 301 redirects within a few days to a few weeks, depending on how frequently it crawls your site. You can speed this up by submitting your updated sitemap in Google Search Console and using the URL Inspection tool to request indexing of the new page.

Will .htaccess redirects slow down my website?

A small number of redirects has negligible impact on speed. However, large .htaccess files with hundreds of rules can add processing overhead. For sites with 100+ redirects, a database-driven solution is faster and easier to manage.

My .htaccess redirect isn't working — what should I check?

First, confirm mod_rewrite is enabled on your server (ask your host if unsure). Check for syntax errors — even a single typo breaks the file. Make sure the rule isn't conflicting with WordPress or CMS rules below it. Clear your browser cache and test in an incognito window, or use an HTTP header checker to see the raw redirect response.

Related Tools