CompleteSEOTools
Home › Developer Tools › Htaccess Generator

Htaccess generator

Tick what you need and copy a commented .htaccess file for Apache or LiteSpeed.

About Htaccess Generator

An .htaccess file lets you change how an Apache or LiteSpeed web server behaves for one site, without touching the main server settings. This generator writes the common rules for you and puts a comment above each block so you can see what it does later. You can add redirects, send visitors to HTTPS or to one version of your domain, turn on caching and compression, add security headers, block addresses and set your own error pages. Everything is built in your browser.

  • Moving to HTTPS without hand-writing rewrite rules.
  • Sending old page addresses to new ones after a redesign.
  • Making repeat visits faster with browser caching and compression.
  • Blocking a noisy address or stopping other sites from embedding your images.

How to use Htaccess Generator

1

Step 1

Tick the sections you want and fill in the boxes that appear for them.

2

Step 2

Read the commented file that builds on the right.

3

Step 3

Copy it into the .htaccess file in your site's root folder and test the site.

Good to know

  • Keep a copy of the old file before you replace it. One typo can give every page a 500 error, and the copy gets you back in a minute.
  • This only works on Apache and LiteSpeed. Nginx ignores .htaccess files completely and needs its own configuration.
  • The HSTS header tells browsers to use HTTPS only, and they remember it for months. Turn it on after you are sure HTTPS works on every page.

Common questions

Where does the .htaccess file go?

In the folder that holds your website, usually public_html or www. Rules in it apply to that folder and everything below it. The name starts with a dot and has no extension.

Why did my site show a 500 error after I pasted it?

Usually a module the rule needs is switched off on your host, or the file has a typo. Remove the last block you added, reload, and add blocks back one at a time to find the cause.

Does this work with WordPress?

Yes, but WordPress writes its own rewrite block between BEGIN WordPress and END WordPress markers. Paste these rules above that block and leave the markers alone.