Advertisement (Policy Compliant)

URL Redirect Code Generator

Generate SEO-safe URL redirect rules and rewrite configurations. Supports Apache, Nginx, PHP, HTML meta refresh, and JavaScript.

Redirect Settings

|
Specify the relative path on your website.
Absolute URL recommended.

Deployment Guide

For **Apache .htaccess**: Open the `.htaccess` file in the root folder of your website and paste the generated lines at the very top. Make sure `RewriteEngine On` is active.

Generated Config / Code

Advertisement (Policy Compliant)

About This Tool

.htaccess Redirect Generator

Generate correct Apache .htaccess redirect rules (301, 302) for any URL without needing to remember complex RewriteRule syntax.

Why Use This Tool?

  • Create 301 permanent redirects when moving pages or changing URLs
  • Generate 302 temporary redirects for maintenance or A/B testing
  • Redirect non-www to www (or vice versa) with correct syntax
  • Used by web developers and site admins managing Apache servers
  • Avoid broken links and preserve SEO link equity when restructuring a site

Overview

Apache .htaccess files are powerful configuration tools that control how your web server handles requests. One of their most common uses is setting up URL redirects — whether you are moving a page to a new URL, changing your domain, redirecting HTTP to HTTPS, enforcing www or non-www versions, or fixing old broken URLs. However, .htaccess redirect syntax using mod_rewrite is notoriously cryptic and easy to get wrong, even for experienced developers. A single typo can break your entire website. Our .htaccess Redirect Generator removes the risk by building the correct, tested redirect rules from a simple form interface. Choose your redirect type (301 Permanent, 302 Temporary), enter the source and destination URLs, and get the exact .htaccess code to copy into your configuration file. The tool generates rules for the most common scenarios including single page redirects, directory redirects, domain changes, HTTP to HTTPS, and www to non-www redirects.

How to Use

  • 1

    Choose the Redirect Type

    Select 301 (Permanent — for moves that affect SEO) or 302 (Temporary — for maintenance or testing).

  • 2

    Enter the Source URL

    Enter the old URL or path you want to redirect from (e.g., /old-page or /old-directory/).

  • 3

    Enter the Destination URL

    Enter the new URL or path to redirect to (e.g., /new-page or https://new-domain.com).

  • 4

    Select Redirect Scope

    Choose whether to redirect a single page, an entire directory, or handle domain-level redirects.

  • 5

    Copy the .htaccess Code

    Click Generate and copy the output. Paste it into your .htaccess file at the top, before other rules.

Frequently Asked Questions

301 is permanent — it tells search engines to transfer full SEO link equity to the new URL and update their index. 302 is temporary — link equity is not fully transferred.
No. Properly implemented 301 redirects pass most of the original page's link authority to the new URL. Use 301 when permanently moving pages.
Place the generated redirect rules in the .htaccess file in your website's root directory (public_html or www). Put redirect rules at the top, before other RewriteRules.
A redirect loop happens when the source and destination redirect to each other infinitely. Add RewriteCond %{REQUEST_URI} !^/new-url to exclude the destination from being redirected.
No. .htaccess files are Apache-specific. For Nginx, redirect rules go in the server block configuration. For LiteSpeed servers (used on Hostinger), .htaccess works the same as Apache.
` block of your HTML page. It will redirect users automatically after a zero-second delay.'; } else if (platform === 'js') { labelDomain.classList.add('opacity-30', 'pointer-events-none'); labelCase.classList.add('hidden'); isDomainCheck.checked = false; instructions.innerHTML = 'For **JavaScript Redirect**: Paste this snippet within `