TapToolsCoffee
All tools

.htaccess Redirect Generator

Developer Tools

Build Apache 301/302 redirects, force HTTPS and www or non-www, ready to paste.

Redirects

.htaccess code

RewriteEngine On

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

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

# Redirects
RewriteRule ^old-page/?$ /new-page [L,R=301]
RewriteRule ^summer-sale/?$ /sale [L,R=302]

What is the .htaccess Redirect Generator?

The .htaccess Redirect Generator writes Apache mod_rewrite rules for you. Add old and new URL paths, choose 301 (permanent) or 302 (temporary), and optionally force HTTPS and a www or non-www address. The result is ready to paste into the .htaccess file in your site's root folder.

How to use this tool

  1. Enter each old path and the new path or full URL it should go to.
  2. Choose 301 Permanent or 302 Temporary for each redirect.
  3. Turn on Force HTTPS and pick www or non-www if you need them.
  4. Copy the code into the .htaccess file in your site's root folder.

Frequently Asked Questions

Use 301 when a page has moved for good; search engines pass its ranking to the new URL. Use 302 for temporary moves, such as a short sale page.

In the root folder of your website (often public_html) on an Apache server. Nginx and most modern hosts do not read .htaccess files.

Yes. Put a full URL such as https://example.com/page in the New URL field.

No. Everything runs in your browser, so nothing is uploaded to a server.