Home/.htaccess Redirect Generator

.htaccess Redirect Generator – Free Online Apache Redirect Tool

4.9 Rating from 137 people who voted
Share this page
.htaccess Redirect Generator Generate safe, SEO-friendly Apache redirect rules instantly
Redirect Configuration

About This .htaccess Redirect Generator

A single misplaced character in a .htaccess file can take an entire Apache-hosted website offline, which makes hand-writing redirect rules a risky habit even for experienced developers. This tool generates clean, tested redirect syntax for the most common scenarios, so you can copy and paste working rules instead of debugging RewriteRule syntax from scratch.

The BigToolSite Team tested every scenario in this generator against a live Apache server to confirm the rules produce the correct redirect behavior and status codes without breaking existing routes.

Five scenarios are covered: custom path redirects, forcing HTTPS, adding or removing a WWW subdomain, and migrating an entire domain to a new one. Each output can include explanatory comments, and you can copy the code directly or download it as a ready-to-upload .htaccess file.

Before uploading any redirect rules to production, it’s worth checking your existing redirects for loops or broken chains with our redirect chain checker. If you’re migrating URLs as part of a larger site restructure, the URL list comparator helps confirm your old and new URL lists line up correctly.

How to Use the .htaccess Redirect Generator

  1. Select a redirect scenario from the dropdown.
  2. Fill in the fields shown for that scenario, such as a source path, destination URL, or domain name.
  3. Check “Include explanatory comments” if you want the code annotated for future reference.
  4. Click “Generate .htaccess Rules” to produce the code.
  5. Copy the code or download it directly as a .htaccess file, then back up your existing file before uploading.

Example Usage

Custom Path Redirect

Use this when a single page has moved, such as after renaming a URL or retiring an old blog post. Enter /old-page/ as the source path and https://example.com/new-page/ as the destination, choose a 301 status code for a permanent move, and the tool generates:

Redirect 301 /old-page/ https://example.com/new-page/

This tells visitors and search engines that anyone requesting the old URL should be sent permanently to the new one, passing along most of the original page’s SEO value.

Force HTTP to HTTPS

Use this once an SSL certificate is installed and you want to make sure no visitor ever lands on the insecure version of the site. Enter your domain, such as example.com, and the tool generates a rule that checks whether the connection is running over HTTPS, and if not, redirects the visitor to the secure version of the exact same URL they requested, preserving the full path and query string.

Non-WWW to WWW

Use this if your site’s canonical version includes the WWW subdomain, such as www.example.com. Enter your domain and the tool generates a rule that catches any visitor arriving at the bare domain and redirects them to the WWW version, which helps avoid duplicate content issues between the two versions of your site.

WWW to Non-WWW

Use this if your site’s canonical version drops the WWW subdomain, such as example.com instead of www.example.com. Enter your domain and the tool generates the reverse rule, catching visitors on the WWW version and sending them to the bare domain, again consolidating all traffic and SEO signals onto a single canonical version.

Old Domain to New Domain

Use this during a full domain migration, such as rebranding from oldsite.com to newsite.com. Enter the old domain and the full new domain URL, and the tool generates a rule that matches both the WWW and non-WWW versions of the old domain and redirects every request, including the original path, to the equivalent location on the new domain. This is one of the most important steps in a domain migration, since it prevents broken links and preserves link equity built up over time.

Yes, it’s completely free with no signup required and no limits on how many rules you can generate.

Use 301 for permanent moves, since it tells search engines to transfer the old page’s ranking signals to the new URL. Use 302 only for temporary changes, since search engines will keep indexing the original URL.

These rules are written for Apache servers using mod_rewrite, which is standard on most shared hosting and cPanel environments. Nginx servers use a different configuration format and won’t read a .htaccess file.

A syntax error in .htaccess can cause a full site outage, often shown as a 500 Internal Server Error. Always keep a backup of your current file so you can quickly restore it if something goes wrong.

Yes. You can generate rules for different scenarios separately and combine them in your final .htaccess file, just make sure RewriteEngine On is only declared once at the top.