Skip to main content
Web Server Tools

Apache .htaccess Generator

Build an .htaccess file that forces HTTPS, picks www or non-www, turns on caching and compression and adds basic security headers.

Free & instant No signup How to use FAQ
Not sure what to enter?

Tick the rules your Apache or shared-hosting site needs and copy the finished .htaccess file into your website's root folder.

What can an .htaccess file do for my website?

On Apache and LiteSpeed hosting, .htaccess lets you change how the server handles your site without access to the main configuration: force every visitor onto HTTPS, choose between www and non-www, tell browsers to cache images and CSS, compress pages and send basic security headers.

How to generate your .htaccess file

  1. Tick the rules you want: Force HTTPS, www redirect, caching, GZIP and security headers.
  2. Click Generate .htaccess.
  3. Copy the result into a file named .htaccess in your website's root folder (back up any existing one first).
  4. Reload your site and test the redirect and headers.

Related checks

Once the file is live, confirm each rule actually works: the HTTPS Redirect Checker for the redirect, the GZIP Compression Checker for compression and the Security Headers Checker for the headers.

Frequently Asked Questions

In the document root of your site - usually public_html or www on shared hosting. The name starts with a dot, so turn on "show hidden files" in your file manager or FTP client if you cannot see an existing one.

It works on Apache and LiteSpeed (used by most shared hosts) when AllowOverride is enabled, which is the default on shared hosting. Nginx ignores .htaccess files - use the Nginx Config Generator instead.

A module used by one of the rules is probably not enabled. Every block in the generated file is wrapped in <IfModule> so this is rare, but if it happens, remove the newest block, reload the page and check the server error log.
Share this tool:
Need a website for your business? Only $599