URL Redirect Code Generator
Generate SEO-safe URL redirect rules and rewrite configurations. Supports Apache, Nginx, PHP, HTML meta refresh, and JavaScript.
Redirect Settings
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
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.