.htaccess Generator

Build redirects and common Apache rules visually — copy or download your .htaccess file.

From (path)To (URL)Type
Force HTTPS

Redirect all HTTP requests to HTTPS automatically.

Force www / non-www

Canonicalise your domain to always use (or not use) www.

Enable GZIP Compression

Compress HTML, CSS, JS, and other text assets to improve load time.

Prevent Directory Listing

Block browsers from seeing folder contents when no index file exists.

Cache Static Assets

Set long-lived cache headers for images, CSS, and JS files.

Block Sensitive Files

Deny access to .env, .git, composer files, and other sensitive paths.

Custom 404 Error Page

Serve a custom page when a URL is not found.

# .htaccess
Apache only: .htaccess files work on Apache web servers. They have no effect on Nginx, Caddy, or other servers. Always test redirects before deploying to production.

How to Use

  • Redirects tab — add rows with a From path (e.g. /old-page), a To URL, and a redirect type (301 = permanent, 302 = temporary).
  • Common Rules tab — toggle individual rules on or off. Some rules reveal extra options when enabled.
  • The generated .htaccess output updates live as you make changes across both tabs.
  • Click Copy or Download to get the file, then place it in your Apache site's root directory (or the relevant subdirectory).
  • Use a 301 redirect for permanent URL changes (search engines will update their index) and 302 for temporary ones.