Category: Developer tools

.htaccess Redirect Generator

System ideaMissing a tool?

Generate Apache redirect and rewrite rules

Generate an Apache .htaccess snippet that forces HTTPS, canonicalizes the www subdomain, adds or removes a trailing slash, and redirects specific paths — all from a form, with mod_rewrite syntax written for you. Built locally in your browser.

.htaccess
RewriteEngine On

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

# Redirect www to non-www
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]

# Path redirects
Redirect 301 /old-page /new-page
Redirect 301 /blog/old-post /blog/new-post

Everything on this page is processed in your browser. Nothing is uploaded.

What this tool does

Apache sites commonly need the same handful of redirects: force every request to HTTPS, pick one canonical form of www vs. non-www so search engines don't split ranking signals between two URLs, standardize trailing slashes, and 301-redirect old paths to their new locations after a restructure. Each needs its own RewriteCond/RewriteRule pair, and the ordering and escaping are easy to get wrong by hand.

How to use it

  1. Enter your domain and toggle the https and www rules you need.
  2. Choose how trailing slashes should be handled.
  3. List any specific old-path to new-path redirects, one per line.
  4. Copy the generated rules into your site's .htaccess file.

Privacy

This tool runs entirely in your browser. Your input is never uploaded, stored or shared — closing the tab removes it.

Frequently asked questions

Where does this file go?
Into the .htaccess file at the root of your Apache site, which requires mod_rewrite to be enabled — most shared hosts and standard Apache installs have it on by default.
Why pick one www form over the other?
Serving a site at both www.example.com and example.com without a redirect splits search engines' view of the page into two separate URLs. Redirecting one to the other consolidates links and ranking signals onto a single canonical address.
Can I combine this with the canonical tag from the Meta Tag Generator?
Yes — the redirect makes sure only one URL form is ever served, and the canonical tag reinforces the same preference to search engines that still crawl the old form.