All tools
SEO Tools
Ads Tools
Link Tools
Social Tools
Text & Content Tools
Utilities
Finance Calculators
Thai Business
Image & Media Tools
Numerology & Fortune
Home & Living
Education
Health

.htaccess Redirect Generator

Generate correct Apache .htaccess redirect rules in seconds — no need to remember RewriteCond and RewriteRule syntax. Pick a preset such as force HTTPS, www to non-www, a single old URL to a new one, or moving an entire domain, choose a 301 or 302 status, and copy the ready-made snippet. Every line comes with a plain-language explanation, and everything is built in your browser with nothing sent to a server.

Use 301 for permanent moves so search engines pass on ranking. Use 302 only for temporary changes.

Your .htaccess code will appear here

Fill in the fields above to generate the redirect rules.

How to use

  1. Choose what to redirect: force HTTPS, www or non-www, a single URL, a whole domain, or trailing slashes.
  2. Fill in the fields shown for that preset — your domain, the old path, or the new destination.
  3. Select a 301 permanent or 302 temporary redirect.
  4. Read the line-by-line explanation to confirm the rule does what you expect.
  5. Copy the snippet and paste it into the .htaccess file in your site’s root folder.

Features

  • Presets for HTTP to HTTPS, www to non-www, single URL, whole domain and trailing slashes
  • Choose 301 permanent or 302 temporary for every rule
  • Plain-language explanation of each RewriteCond and RewriteRule line
  • Domain and path inputs are validated to catch typos before you paste
  • Copy-ready output — no mod_rewrite syntax to memorise
  • 100% in-browser: your domain and URLs never leave your device

Frequently asked questions

What is the difference between a 301 and 302 redirect?
A 301 is a permanent redirect and tells search engines to pass ranking to the new URL, so it is best for site moves. A 302 is temporary and keeps the original URL indexed. Use 301 unless the change is genuinely short-lived.
Where do I put the .htaccess redirect code?
Place it in the .htaccess file in the root folder of your website, usually public_html or www. If the file does not exist, create one named exactly .htaccess. Back up any existing file first, because a wrong rule can break the whole site.
How do I redirect HTTP to HTTPS in .htaccess?
Select the Force HTTPS preset. It adds a RewriteCond that checks whether the connection is plain HTTP and a RewriteRule that rebuilds the same host and path on https://, so every page keeps its address but becomes secure.
Does this redirect keep the URL path?
Yes. The www, non-www, HTTPS and whole-domain presets use $1 to carry the original path across, so example.com/blog redirects to the matching page on the new host rather than the homepage.
Is this .htaccess redirect generator free?
Yes, it is completely free with no sign-up. All rules are generated in your browser, so your domain names and URLs are never uploaded or stored anywhere.