Skip to content

Htaccess Redirect

Discover the power of URL redirection with our comprehensive guide. Learn how to use redirect generators effectively for seamless website navigation and enhanced SEO performance.

  • Instant results
  • Secure & private
  • Works on any device

Share on Social Media:

What Does the Htaccess Redirect Generator Do?

Your site can usually be reached at both example.com and www.example.com. Search engines may treat these as two separate sites, splitting links and creating duplicate content. A permanent redirect picks one version and sends every visitor to it.

This htaccess redirect generator writes the Apache mod_rewrite rules for that redirect. Choose non-www to www or www to non-www, enter your domain, and copy the code into the .htaccess file in your site's root folder. The rules use a 301 (permanent) redirect and keep the rest of the path.

Option 1Redirect from non-www to www
Option 2Redirect from www to non-www
Type301 permanent redirect
ServerApache with mod_rewrite

How to Create an Htaccess Redirect

  1. 1Select the redirect type — non-www to www, or www to non-www.
  2. 2Enter your domain — as a full URL, for example https://example.com.
  3. 3Click Get Your HtAccess Code — to generate the rules.
  4. 4Add it to .htaccess — copy the code or save it as TXT, then paste it into the .htaccess file in your site root.
Canonical domain Duplicate content fixes Site launches Domain migrations WordPress on Apache SEO clean-up

Why Use This Redirect Generator?

No regex to write

Get working RewriteCond and RewriteRule lines without learning mod_rewrite syntax.

Both directions covered

Generate rules for whichever version of your domain you want to keep.

Path is preserved

Visitors to any page land on the same page on your preferred domain.

Copy or save

Copy the rules to your clipboard or download them as a text file.

Frequently Asked Questions

It is a rule in Apache's .htaccess configuration file that automatically sends visitors and search engines from one URL to another.
Either works for SEO. What matters is choosing one and redirecting the other to it consistently, so all links and signals point to a single version.
Paste it into the .htaccess file in your website's root folder (often public_html). If the file already has a RewriteEngine On line, add the rules after it rather than duplicating it.
Yes. The rules use R=301, which tells browsers and search engines the move is permanent.
The rule redirects to http://. If your site runs on HTTPS, change http:// to https:// in the RewriteRule line so visitors are not sent through an extra redirect.
No. .htaccess files and these rules are for Apache (and compatible servers such as LiteSpeed). Nginx and IIS use different configuration formats.
Visit the version of your domain that should redirect and check the address bar, or use the Get HTTP Header tool to confirm the final URL.