Category: Developer tools

.htaccess Redirect Generator

System ideaMissing a tool?

Generate Apache redirect and rewrite rules

Force HTTPS, canonicalize www, add or remove a trailing slash and redirect old paths — LocalTools writes the mod_rewrite syntax for you, 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

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.

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, and list any specific old-path to new-path redirects, one per line.
  3. 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?
Put the rules in the .htaccess file at the document root of your Apache site — the directory your pages are actually served from. Apache reads the file per directory, and mod_rewrite has to be enabled for the RewriteCond and RewriteRule lines to take effect.
Why pick one www form over the other?
If the same page answers at both www and non-www, ranking signals get split across two URLs. Choose one canonical form, 301-redirect the other to it, and search engines consolidate on a single address. The generator writes the rule for whichever form you select.
Can I combine this with the canonical tag from the Meta Tag Generator?
Yes. They work at different layers and nothing here links them automatically: this tool only outputs an .htaccess snippet you paste yourself, while a canonical tag is HTML you add to the page. Just keep both pointing at the same preferred URL.
Is my input, file, or result uploaded?
No. Your domain, the rule toggles, the path list and the generated snippet stay in the browser and are not uploaded to LocalTools.
What does this tool not support?
It writes a text snippet, nothing more. It does not connect to your server, deploy or validate the file, test the rules against live URLs, or crawl your site, and there are no accounts, sync or cloud history. Formats, options and batch features not listed on this page are not supported.